use :: c2rust_bitfields;
use :: libc;
extern "C" {
    pub type re_dfa_t;
    pub type event_base;
    pub type evbuffer;
    pub type bufferevent_ops;
    pub type args;
    pub type tmuxpeer;
    pub type hyperlinks;
    pub type screen_write_cline;
    pub type screen_sel;
    pub type screen_titles;
    pub type environ;
    pub type options;
    pub type cmdq_item;
    pub type paste_buffer;
    pub type input_ctx;
    pub type cmds;
    pub type tty_key;
    pub type tty_code;
    pub type job;
    pub type control_state;
    pub type cmdq_list;
    pub type options_entry;
    fn getuid() -> __uid_t;
    fn getpid() -> __pid_t;
    fn gethostname(__name: *mut i8, __len: size_t) -> i32;
    fn __ctype_b_loc() -> *mut *const u16;
    fn fnmatch(__pattern: *const i8, __name: *const i8, __flags: i32) -> i32;
    fn dirname(__path: *mut i8) -> *mut i8;
    fn __xpg_basename(__path: *mut i8) -> *mut i8;
    fn fabs(_: f64) -> f64;
    fn fmod(_: f64, _: f64) -> f64;
    fn getpwuid(__uid: __uid_t) -> *mut passwd;
    fn regcomp(__preg: *mut regex_t, __pattern: *const i8, __cflags: i32) -> i32;
    fn regexec(
        __preg: *const regex_t,
        __String: *const i8,
        __nmatch: size_t,
        __pmatch: *mut regmatch_t,
        __eflags: i32,
    ) -> i32;
    fn regfree(__preg: *mut regex_t);
    fn strtod(_: *const i8, _: *mut *mut i8) -> f64;
    fn free(_: *mut libc::c_void);
    fn bsearch(
        __key: *const libc::c_void,
        __base: *const libc::c_void,
        __nmemb: size_t,
        __size: size_t,
        __compar: __compar_fn_t,
    ) -> *mut libc::c_void;
    fn memcpy(_: *mut libc::c_void, _: *const libc::c_void, _: u64) -> *mut libc::c_void;
    fn memset(_: *mut libc::c_void, _: i32, _: u64) -> *mut libc::c_void;
    fn memcmp(_: *const libc::c_void, _: *const libc::c_void, _: u64) -> i32;
    fn strcmp(_: *const i8, _: *const i8) -> i32;
    fn strchr(_: *const i8, _: i32) -> *mut i8;
    fn strcspn(_: *const i8, _: *const i8) -> u64;
    fn strstr(_: *const i8, _: *const i8) -> *mut i8;
    fn strlen(_: *const i8) -> u64;
    fn time(__timer: *mut time_t) -> time_t;
    fn strftime(__s: *mut i8, __maxsize: size_t, __format: *const i8, __tp: *const tm) -> size_t;
    fn localtime_r(__timer: *const time_t, __tp: *mut tm) -> *mut tm;
    fn ctime_r(__timer: *const time_t, __buf: *mut i8) -> *mut i8;
    fn evbuffer_new() -> *mut evbuffer;
    fn evbuffer_free(buf: *mut evbuffer);
    fn evbuffer_get_length(buf: *const evbuffer) -> size_t;
    fn evbuffer_add(buf: *mut evbuffer, data: *const libc::c_void, datlen: size_t) -> i32;
    fn evbuffer_add_printf(buf: *mut evbuffer, fmt: *const i8, _: ...) -> i32;
    fn evbuffer_pullup(buf: *mut evbuffer, size: ssize_t) -> *mut u8;
    fn evbuffer_readline(buffer: *mut evbuffer) -> *mut i8;
    fn strtonum(_: *const i8, _: i64, _: i64, _: *mut *const i8) -> i64;
    fn strlcat(_: *mut i8, _: *const i8, _: size_t) -> size_t;
    fn xmalloc(_: size_t) -> *mut libc::c_void;
    fn xcalloc(_: size_t, _: size_t) -> *mut libc::c_void;
    fn xrealloc(_: *mut libc::c_void, _: size_t) -> *mut libc::c_void;
    fn xreallocarray(_: *mut libc::c_void, _: size_t, _: size_t) -> *mut libc::c_void;
    fn xstrdup(_: *const i8) -> *mut i8;
    fn xstrndup(_: *const i8, _: size_t) -> *mut i8;
    fn xasprintf(_: *mut *mut i8, _: *const i8, _: ...) -> i32;
    fn xvasprintf(_: *mut *mut i8, _: *const i8, _: ::core::ffi::VaList) -> i32;
    fn xsnprintf(_: *mut i8, _: size_t, _: *const i8, _: ...) -> i32;
    static mut global_options: *mut options;
    static mut global_s_options: *mut options;
    static mut global_w_options: *mut options;
    static mut global_environ: *mut environ;
    static mut start_time: timeval;
    static mut socket_path: *const i8;
    fn sig2name(_: i32) -> *const i8;
    fn getversion() -> *const i8;
    fn proc_get_peer_uid(_: *mut tmuxpeer) -> uid_t;
    static mut cfg_files: *mut *mut i8;
    static mut cfg_nfiles: u_int;
    fn paste_buffer_name(_: *mut paste_buffer) -> *const i8;
    fn paste_buffer_created(_: *mut paste_buffer) -> time_t;
    fn paste_buffer_data(_: *mut paste_buffer, _: *mut size_t) -> *const i8;
    fn paste_get_top(_: *mut *const i8) -> *mut paste_buffer;
    fn paste_make_sample(_: *mut paste_buffer) -> *mut i8;
    fn job_free(_: *mut job);
    fn cmdq_get_event(_: *mut cmdq_item) -> *mut key_event;
    fn cmdq_merge_formats(_: *mut cmdq_item, _: *mut format_tree);
    fn tty_window_offset(
        _: *mut tty,
        _: *mut u_int,
        _: *mut u_int,
        _: *mut u_int,
        _: *mut u_int,
    ) -> i32;
    fn options_get_number(_: *mut options, _: *const i8) -> i64;
    fn cmd_stringify_argv(_: i32, _: *mut *mut i8) -> *mut i8;
    fn tty_default_colours(_: *mut grid_cell, _: *mut window_pane);
    fn cmd_mouse_at(
        _: *mut window_pane,
        _: *mut mouse_event,
        _: *mut u_int,
        _: *mut u_int,
        _: i32,
    ) -> i32;
    fn cmd_mouse_pane(
        _: *mut mouse_event,
        _: *mut *mut session,
        _: *mut *mut winlink,
    ) -> *mut window_pane;
    fn options_get_string(_: *mut options, _: *const i8) -> *const i8;
    fn tty_get_features(_: i32) -> *const i8;
    fn cmdq_print(_: *mut cmdq_item, _: *const i8, _: ...);
    fn cmd_free_argv(_: i32, _: *mut *mut i8);
    fn format_width(_: *const i8) -> u_int;
    fn format_trim_right(_: *const i8, _: u_int) -> *mut i8;
    fn format_trim_left(_: *const i8, _: u_int) -> *mut i8;
    fn environ_find(_: *mut environ, _: *const i8) -> *mut environ_entry;
    fn options_to_string(_: *mut options_entry, _: i32, _: i32) -> *mut i8;
    fn options_parse_get(_: *mut options, _: *const i8, _: *mut i32, _: i32) -> *mut options_entry;
    fn job_get_data(_: *mut job) -> *mut libc::c_void;
    fn job_get_event(_: *mut job) -> *mut bufferevent;
    fn cmdq_get_target_client(_: *mut cmdq_item) -> *mut client;
    fn cmdq_get_target(_: *mut cmdq_item) -> *mut cmd_find_state;
    fn job_run(
        _: *const i8,
        _: i32,
        _: *mut *mut i8,
        _: *mut environ,
        _: *mut session,
        _: *const i8,
        _: job_update_cb,
        _: job_complete_cb,
        _: job_free_cb,
        _: *mut libc::c_void,
        _: i32,
        _: i32,
        _: i32,
    ) -> *mut job;
    fn cmdq_get_client(_: *mut cmdq_item) -> *mut client;
    static mut clients: clients;
    fn server_client_unref(_: *mut client);
    fn server_client_get_cwd(_: *mut client, _: *mut session) -> *const i8;
    fn server_status_client(_: *mut client);
    fn colour_fromstring(s: *const i8) -> i32;
    fn colour_force_rgb(_: i32) -> i32;
    fn window_pane_search(_: *mut window_pane, _: *const i8, _: i32, _: i32) -> u_int;
    fn server_client_get_flags(_: *mut client) -> *const i8;
    fn server_client_get_key_table(_: *mut client) -> *const i8;
    fn grid_view_get_cell(_: *mut grid, _: u_int, _: u_int, _: *mut grid_cell);
    fn grid_get_line(_: *mut grid, _: u_int) -> *mut grid_line;
    fn status_get_range(_: *mut client, _: u_int, _: u_int) -> *mut style_range;
    fn window_pane_mode(_: *mut window_pane) -> i32;
    fn grid_line_length(_: *mut grid, _: u_int) -> u_int;
    fn grid_peek_line(_: *mut grid, _: u_int) -> *const grid_line;
    fn grid_get_cell(_: *mut grid, _: u_int, _: u_int, _: *mut grid_cell);
    fn colour_tostring(_: i32) -> *const i8;
    fn window_pane_index(_: *mut window_pane, _: *mut u_int) -> i32;
    fn winlinks_RB_NEXT(_: *mut winlink) -> *mut winlink;
    fn winlink_count(_: *mut winlinks) -> u_int;
    fn server_check_marked() -> i32;
    static mut marked_pane: cmd_find_state;
    fn window_count_panes(_: *mut window) -> u_int;
    fn window_printable_flags(_: *mut winlink, _: i32) -> *const i8;
    fn winlinks_RB_MINMAX(_: *mut winlinks, _: i32) -> *mut winlink;
    fn utf8_padcstr(_: *const i8, _: u_int) -> *mut i8;
    fn utf8_rpadcstr(_: *const i8, _: u_int) -> *mut i8;
    static window_buffer_mode: window_mode;
    fn session_alive(_: *mut session) -> i32;
    static window_client_mode: window_mode;
    fn window_copy_get_line(_: *mut window_pane, _: u_int) -> *mut i8;
    fn utf8_set(_: *mut utf8_data, _: u_char);
    fn window_copy_get_word(_: *mut window_pane, _: u_int, _: u_int) -> *mut i8;
    fn utf8_cstrhas(_: *const i8, _: *const utf8_data) -> i32;
    fn utf8_tocstr(_: *mut utf8_data) -> *mut i8;
    static mut next_session_id: u_int;
    fn osdep_get_name(_: i32, _: *mut i8) -> *mut i8;
    fn parse_window_name(_: *const i8) -> *mut i8;
    fn osdep_get_cwd(_: i32) -> *mut i8;
    fn layout_dump(_: *mut layout_cell) -> *mut i8;
    fn session_is_linked(_: *mut session, _: *mut window) -> i32;
    fn sessions_RB_MINMAX(_: *mut sessions, _: i32) -> *mut session;
    static mut sessions: sessions;
    fn sessions_RB_NEXT(_: *mut session) -> *mut session;
    fn session_group_attached_count(_: *mut session_group) -> u_int;
    fn session_group_count(_: *mut session_group) -> u_int;
    fn session_group_contains(_: *mut session) -> *mut session_group;
    static window_tree_mode: window_mode;
    fn log_get_level() -> i32;
    fn log_debug(_: *const i8, _: ...);
    fn fatalx(_: *const i8, _: ...) -> !;
    fn regsub(_: *const i8, _: *const i8, _: *const i8, _: i32) -> *mut i8;
    fn hyperlinks_get(
        _: *mut hyperlinks,
        _: u_int,
        _: *mut *const i8,
        _: *mut *const i8,
        _: *mut *const i8,
    ) -> i32;
}
pub type __builtin_va_list = [__va_list_tag; 1];
#[derive(Copy, Clone)]
#[repr(C)]
pub struct __va_list_tag {
    pub gp_offset: u32,
    pub fp_offset: u32,
    pub overflow_arg_area: *mut libc::c_void,
    pub reg_save_area: *mut libc::c_void,
}
pub type __u_char = u8;
pub type __u_short = u16;
pub type __u_int = u32;
pub type __uint8_t = u8;
pub type __uint64_t = u64;
pub type __uid_t = u32;
pub type __gid_t = u32;
pub type __pid_t = i32;
pub type __time_t = i64;
pub type __suseconds_t = i64;
pub type __ssize_t = i64;
pub type u_char = __u_char;
pub type u_short = __u_short;
pub type u_int = __u_int;
pub type uid_t = __uid_t;
pub type pid_t = __pid_t;
pub type ssize_t = __ssize_t;
pub type time_t = __time_t;
pub type size_t = u64;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct timeval {
    pub tv_sec: __time_t,
    pub tv_usec: __suseconds_t,
}
pub type C2RustUnnamed = u32;
pub const _ISalnum: C2RustUnnamed = 8;
pub const _ISpunct: C2RustUnnamed = 4;
pub const _IScntrl: C2RustUnnamed = 2;
pub const _ISblank: C2RustUnnamed = 1;
pub const _ISgraph: C2RustUnnamed = 32768;
pub const _ISprint: C2RustUnnamed = 16384;
pub const _ISspace: C2RustUnnamed = 8192;
pub const _ISxdigit: C2RustUnnamed = 4096;
pub const _ISdigit: C2RustUnnamed = 2048;
pub const _ISalpha: C2RustUnnamed = 1024;
pub const _ISlower: C2RustUnnamed = 512;
pub const _ISupper: C2RustUnnamed = 256;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct passwd {
    pub pw_name: *mut i8,
    pub pw_passwd: *mut i8,
    pub pw_uid: __uid_t,
    pub pw_gid: __gid_t,
    pub pw_gecos: *mut i8,
    pub pw_dir: *mut i8,
    pub pw_shell: *mut i8,
}
pub type __re_long_size_t = u64;
pub type reg_syntax_t = u64;
#[derive(Copy, Clone, BitfieldStruct)]
#[repr(C)]
pub struct re_pattern_buffer {
    pub buffer: *mut re_dfa_t,
    pub allocated: __re_long_size_t,
    pub used: __re_long_size_t,
    pub syntax: reg_syntax_t,
    pub fastmap: *mut i8,
    pub translate: *mut u8,
    pub re_nsub: size_t,
    #[bitfield(name = "can_be_null", ty = "u32", bits = "0..=0")]
    #[bitfield(name = "regs_allocated", ty = "u32", bits = "1..=2")]
    #[bitfield(name = "fastmap_accurate", ty = "u32", bits = "3..=3")]
    #[bitfield(name = "no_sub", ty = "u32", bits = "4..=4")]
    #[bitfield(name = "not_bol", ty = "u32", bits = "5..=5")]
    #[bitfield(name = "not_eol", ty = "u32", bits = "6..=6")]
    #[bitfield(name = "newline_anchor", ty = "u32", bits = "7..=7")]
    pub can_be_null_regs_allocated_fastmap_accurate_no_sub_not_bol_not_eol_newline_anchor: [u8; 1],
    #[bitfield(padding)]
    pub c2rust_padding: [u8; 7],
}
pub type regex_t = re_pattern_buffer;
pub type regoff_t = i32;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct regmatch_t {
    pub rm_so: regoff_t,
    pub rm_eo: regoff_t,
}
pub type va_list = __builtin_va_list;
pub type __compar_fn_t =
    Option<unsafe extern "C" fn(*const libc::c_void, *const libc::c_void) -> i32>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tm {
    pub tm_sec: i32,
    pub tm_min: i32,
    pub tm_hour: i32,
    pub tm_mday: i32,
    pub tm_mon: i32,
    pub tm_year: i32,
    pub tm_wday: i32,
    pub tm_yday: i32,
    pub tm_isdst: i32,
    pub tm_gmtoff: i64,
    pub tm_zone: *const i8,
}
pub type cc_t = u8;
pub type speed_t = u32;
pub type tcflag_t = u32;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct termios {
    pub c_iflag: tcflag_t,
    pub c_oflag: tcflag_t,
    pub c_cflag: tcflag_t,
    pub c_lflag: tcflag_t,
    pub c_line: cc_t,
    pub c_cc: [cc_t; 32],
    pub c_ispeed: speed_t,
    pub c_ospeed: speed_t,
}
pub type uint8_t = __uint8_t;
pub type uint64_t = __uint64_t;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event {
    pub ev_evcallback: event_callback,
    pub ev_timeout_pos: C2RustUnnamed_5,
    pub ev_fd: i32,
    pub ev_base: *mut event_base,
    pub ev_: C2RustUnnamed_0,
    pub ev_events: i16,
    pub ev_res: i16,
    pub ev_timeout: timeval,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_0 {
    pub ev_io: C2RustUnnamed_3,
    pub ev_signal: C2RustUnnamed_1,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_1 {
    pub ev_signal_next: C2RustUnnamed_2,
    pub ev_ncalls: i16,
    pub ev_pncalls: *mut i16,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_2 {
    pub le_next: *mut event,
    pub le_prev: *mut *mut event,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_3 {
    pub ev_io_next: C2RustUnnamed_4,
    pub ev_timeout: timeval,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_4 {
    pub le_next: *mut event,
    pub le_prev: *mut *mut event,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_5 {
    pub ev_next_with_common_timeout: C2RustUnnamed_6,
    pub min_heap_idx: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_6 {
    pub tqe_next: *mut event,
    pub tqe_prev: *mut *mut event,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event_callback {
    pub evcb_active_next: C2RustUnnamed_8,
    pub evcb_flags: i16,
    pub evcb_pri: uint8_t,
    pub evcb_closure: uint8_t,
    pub evcb_cb_union: C2RustUnnamed_7,
    pub evcb_arg: *mut libc::c_void,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_7 {
    pub evcb_callback: Option<unsafe extern "C" fn(i32, i16, *mut libc::c_void) -> ()>,
    pub evcb_selfcb: Option<unsafe extern "C" fn(*mut event_callback, *mut libc::c_void) -> ()>,
    pub evcb_evfinalize: Option<unsafe extern "C" fn(*mut event, *mut libc::c_void) -> ()>,
    pub evcb_cbfinalize: Option<unsafe extern "C" fn(*mut event_callback, *mut libc::c_void) -> ()>,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_8 {
    pub tqe_next: *mut event_callback,
    pub tqe_prev: *mut *mut event_callback,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct bufferevent {
    pub ev_base: *mut event_base,
    pub be_ops: *const bufferevent_ops,
    pub ev_read: event,
    pub ev_write: event,
    pub input: *mut evbuffer,
    pub output: *mut evbuffer,
    pub wm_read: event_watermark,
    pub wm_write: event_watermark,
    pub readcb: bufferevent_data_cb,
    pub writecb: bufferevent_data_cb,
    pub errorcb: bufferevent_event_cb,
    pub cbarg: *mut libc::c_void,
    pub timeout_read: timeval,
    pub timeout_write: timeval,
    pub enabled: i16,
}
pub type bufferevent_event_cb =
    Option<unsafe extern "C" fn(*mut bufferevent, i16, *mut libc::c_void) -> ()>;
pub type bufferevent_data_cb =
    Option<unsafe extern "C" fn(*mut bufferevent, *mut libc::c_void) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct event_watermark {
    pub low: size_t,
    pub high: size_t,
}
pub type bitstr_t = u8;
pub type msgtype = u32;
pub const MSG_READ_CANCEL: msgtype = 307;
pub const MSG_WRITE_CLOSE: msgtype = 306;
pub const MSG_WRITE_READY: msgtype = 305;
pub const MSG_WRITE: msgtype = 304;
pub const MSG_WRITE_OPEN: msgtype = 303;
pub const MSG_READ_DONE: msgtype = 302;
pub const MSG_READ: msgtype = 301;
pub const MSG_READ_OPEN: msgtype = 300;
pub const MSG_FLAGS: msgtype = 218;
pub const MSG_EXEC: msgtype = 217;
pub const MSG_WAKEUP: msgtype = 216;
pub const MSG_UNLOCK: msgtype = 215;
pub const MSG_SUSPEND: msgtype = 214;
pub const MSG_OLDSTDOUT: msgtype = 213;
pub const MSG_OLDSTDIN: msgtype = 212;
pub const MSG_OLDSTDERR: msgtype = 211;
pub const MSG_SHUTDOWN: msgtype = 210;
pub const MSG_SHELL: msgtype = 209;
pub const MSG_RESIZE: msgtype = 208;
pub const MSG_READY: msgtype = 207;
pub const MSG_LOCK: msgtype = 206;
pub const MSG_EXITING: msgtype = 205;
pub const MSG_EXITED: msgtype = 204;
pub const MSG_EXIT: msgtype = 203;
pub const MSG_DETACHKILL: msgtype = 202;
pub const MSG_DETACH: msgtype = 201;
pub const MSG_COMMAND: msgtype = 200;
pub const MSG_IDENTIFY_TERMINFO: msgtype = 112;
pub const MSG_IDENTIFY_LONGFLAGS: msgtype = 111;
pub const MSG_IDENTIFY_STDOUT: msgtype = 110;
pub const MSG_IDENTIFY_FEATURES: msgtype = 109;
pub const MSG_IDENTIFY_CWD: msgtype = 108;
pub const MSG_IDENTIFY_CLIENTPID: msgtype = 107;
pub const MSG_IDENTIFY_DONE: msgtype = 106;
pub const MSG_IDENTIFY_ENVIRON: msgtype = 105;
pub const MSG_IDENTIFY_STDIN: msgtype = 104;
pub const MSG_IDENTIFY_OLDCWD: msgtype = 103;
pub const MSG_IDENTIFY_TTYNAME: msgtype = 102;
pub const MSG_IDENTIFY_TERM: msgtype = 101;
pub const MSG_IDENTIFY_FLAGS: msgtype = 100;
pub const MSG_VERSION: msgtype = 12;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client {
    pub name: *const i8,
    pub peer: *mut tmuxpeer,
    pub queue: *mut cmdq_list,
    pub windows: client_windows,
    pub control_state: *mut control_state,
    pub pause_age: u_int,
    pub pid: pid_t,
    pub fd: i32,
    pub out_fd: i32,
    pub event: event,
    pub retval: i32,
    pub creation_time: timeval,
    pub activity_time: timeval,
    pub last_activity_time: timeval,
    pub environ: *mut environ,
    pub jobs: *mut format_job_tree,
    pub title: *mut i8,
    pub path: *mut i8,
    pub cwd: *const i8,
    pub term_name: *mut i8,
    pub term_features: i32,
    pub term_type: *mut i8,
    pub term_caps: *mut *mut i8,
    pub term_ncaps: u_int,
    pub ttyname: *mut i8,
    pub tty: tty,
    pub written: size_t,
    pub discarded: size_t,
    pub redraw: size_t,
    pub repeat_timer: event,
    pub click_timer: event,
    pub click_button: u_int,
    pub click_event: mouse_event,
    pub status: status_line,
    pub flags: uint64_t,
    pub exit_type: C2RustUnnamed_32,
    pub exit_msgtype: msgtype,
    pub exit_session: *mut i8,
    pub exit_message: *mut i8,
    pub keytable: *mut key_table,
    pub last_key: key_code,
    pub redraw_panes: uint64_t,
    pub redraw_scrollbars: uint64_t,
    pub message_ignore_keys: i32,
    pub message_ignore_styles: i32,
    pub message_string: *mut i8,
    pub message_timer: event,
    pub prompt_string: *mut i8,
    pub prompt_buffer: *mut utf8_data,
    pub prompt_last: *mut i8,
    pub prompt_index: size_t,
    pub prompt_inputcb: prompt_input_cb,
    pub prompt_freecb: prompt_free_cb,
    pub prompt_data: *mut libc::c_void,
    pub prompt_hindex: [u_int; 4],
    pub prompt_mode: C2RustUnnamed_29,
    pub prompt_saved: *mut utf8_data,
    pub prompt_flags: i32,
    pub prompt_type: prompt_type,
    pub prompt_cursor: i32,
    pub session: *mut session,
    pub last_session: *mut session,
    pub references: i32,
    pub pan_window: *mut libc::c_void,
    pub pan_ox: u_int,
    pub pan_oy: u_int,
    pub overlay_check: overlay_check_cb,
    pub overlay_mode: overlay_mode_cb,
    pub overlay_draw: overlay_draw_cb,
    pub overlay_key: overlay_key_cb,
    pub overlay_free: overlay_free_cb,
    pub overlay_resize: overlay_resize_cb,
    pub overlay_data: *mut libc::c_void,
    pub overlay_timer: event,
    pub files: client_files,
    pub clipboard_panes: *mut u_int,
    pub clipboard_npanes: u_int,
    pub entry: C2RustUnnamed_9,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_9 {
    pub tqe_next: *mut client,
    pub tqe_prev: *mut *mut client,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_files {
    pub rbh_root: *mut client_file,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_file {
    pub c: *mut client,
    pub peer: *mut tmuxpeer,
    pub tree: *mut client_files,
    pub references: i32,
    pub stream: i32,
    pub path: *mut i8,
    pub buffer: *mut evbuffer,
    pub event: *mut bufferevent,
    pub fd: i32,
    pub error: i32,
    pub closed: i32,
    pub cb: client_file_cb,
    pub data: *mut libc::c_void,
    pub entry: C2RustUnnamed_10,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_10 {
    pub rbe_left: *mut client_file,
    pub rbe_right: *mut client_file,
    pub rbe_parent: *mut client_file,
    pub rbe_color: i32,
}
pub type client_file_cb = Option<
    unsafe extern "C" fn(*mut client, *const i8, i32, i32, *mut evbuffer, *mut libc::c_void) -> (),
>;
pub type overlay_resize_cb = Option<unsafe extern "C" fn(*mut client, *mut libc::c_void) -> ()>;
pub type overlay_free_cb = Option<unsafe extern "C" fn(*mut client, *mut libc::c_void) -> ()>;
pub type overlay_key_cb =
    Option<unsafe extern "C" fn(*mut client, *mut libc::c_void, *mut key_event) -> i32>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_event {
    pub key: key_code,
    pub m: mouse_event,
    pub buf: *mut i8,
    pub len: size_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct mouse_event {
    pub valid: i32,
    pub ignore: i32,
    pub key: key_code,
    pub statusat: i32,
    pub statuslines: u_int,
    pub x: u_int,
    pub y: u_int,
    pub b: u_int,
    pub lx: u_int,
    pub ly: u_int,
    pub lb: u_int,
    pub ox: u_int,
    pub oy: u_int,
    pub s: i32,
    pub w: i32,
    pub wp: i32,
    pub sgr_type: u_int,
    pub sgr_b: u_int,
}
pub type key_code = u64;
pub type overlay_draw_cb =
    Option<unsafe extern "C" fn(*mut client, *mut libc::c_void, *mut screen_redraw_ctx) -> ()>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct screen_redraw_ctx {
    pub c: *mut client,
    pub statuslines: u_int,
    pub statustop: i32,
    pub pane_status: i32,
    pub pane_lines: pane_lines,
    pub pane_scrollbars: i32,
    pub pane_scrollbars_pos: i32,
    pub no_pane_gc: grid_cell,
    pub no_pane_gc_set: i32,
    pub sx: u_int,
    pub sy: u_int,
    pub ox: u_int,
    pub oy: u_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct grid_cell {
    pub data: utf8_data,
    pub attr: u_short,
    pub flags: u_char,
    pub fg: i32,
    pub bg: i32,
    pub us: i32,
    pub link: u_int,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct utf8_data {
    pub data: [u_char; 21],
    pub have: u_char,
    pub size: u_char,
    pub width: u_char,
}
pub type pane_lines = u32;
pub const PANE_LINES_NUMBER: pane_lines = 4;
pub const PANE_LINES_SIMPLE: pane_lines = 3;
pub const PANE_LINES_HEAVY: pane_lines = 2;
pub const PANE_LINES_DOUBLE: pane_lines = 1;
pub const PANE_LINES_SINGLE: pane_lines = 0;
pub type overlay_mode_cb = Option<
    unsafe extern "C" fn(*mut client, *mut libc::c_void, *mut u_int, *mut u_int) -> *mut screen,
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct screen {
    pub title: *mut i8,
    pub path: *mut i8,
    pub titles: *mut screen_titles,
    pub grid: *mut grid,
    pub cx: u_int,
    pub cy: u_int,
    pub cstyle: screen_cursor_style,
    pub default_cstyle: screen_cursor_style,
    pub ccolour: i32,
    pub default_ccolour: i32,
    pub rupper: u_int,
    pub rlower: u_int,
    pub mode: i32,
    pub default_mode: i32,
    pub saved_cx: u_int,
    pub saved_cy: u_int,
    pub saved_grid: *mut grid,
    pub saved_cell: grid_cell,
    pub saved_flags: i32,
    pub tabs: *mut bitstr_t,
    pub sel: *mut screen_sel,
    pub write_list: *mut screen_write_cline,
    pub hyperlinks: *mut hyperlinks,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct grid {
    pub flags: i32,
    pub sx: u_int,
    pub sy: u_int,
    pub hscrolled: u_int,
    pub hsize: u_int,
    pub hlimit: u_int,
    pub linedata: *mut grid_line,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct grid_line {
    pub celldata: *mut grid_cell_entry,
    pub cellused: u_int,
    pub cellsize: u_int,
    pub extddata: *mut grid_extd_entry,
    pub extdsize: u_int,
    pub flags: i32,
    pub time: time_t,
}
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct grid_extd_entry {
    pub data: utf8_char,
    pub attr: u_short,
    pub flags: u_char,
    pub fg: i32,
    pub bg: i32,
    pub us: i32,
    pub link: u_int,
}
pub type utf8_char = u_int;
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct grid_cell_entry {
    pub c2rust_unnamed: C2RustUnnamed_11,
    pub flags: u_char,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub union C2RustUnnamed_11 {
    pub offset: u_int,
    pub data: C2RustUnnamed_12,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_12 {
    pub attr: u_char,
    pub fg: u_char,
    pub bg: u_char,
    pub data: u_char,
}
pub type screen_cursor_style = u32;
pub const SCREEN_CURSOR_BAR: screen_cursor_style = 3;
pub const SCREEN_CURSOR_UNDERLINE: screen_cursor_style = 2;
pub const SCREEN_CURSOR_BLOCK: screen_cursor_style = 1;
pub const SCREEN_CURSOR_DEFAULT: screen_cursor_style = 0;
pub type overlay_check_cb = Option<
    unsafe extern "C" fn(
        *mut client,
        *mut libc::c_void,
        u_int,
        u_int,
        u_int,
        *mut overlay_ranges,
    ) -> (),
>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct overlay_ranges {
    pub px: [u_int; 3],
    pub nx: [u_int; 3],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct session {
    pub id: u_int,
    pub name: *mut i8,
    pub cwd: *const i8,
    pub creation_time: timeval,
    pub last_attached_time: timeval,
    pub activity_time: timeval,
    pub last_activity_time: timeval,
    pub lock_timer: event,
    pub curw: *mut winlink,
    pub lastw: winlink_stack,
    pub windows: winlinks,
    pub statusat: i32,
    pub statuslines: u_int,
    pub options: *mut options,
    pub flags: i32,
    pub attached: u_int,
    pub tio: *mut termios,
    pub environ: *mut environ,
    pub references: i32,
    pub gentry: C2RustUnnamed_14,
    pub entry: C2RustUnnamed_13,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_13 {
    pub rbe_left: *mut session,
    pub rbe_right: *mut session,
    pub rbe_parent: *mut session,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_14 {
    pub tqe_next: *mut session,
    pub tqe_prev: *mut *mut session,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct winlinks {
    pub rbh_root: *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct winlink {
    pub idx: i32,
    pub session: *mut session,
    pub window: *mut window,
    pub flags: i32,
    pub entry: C2RustUnnamed_17,
    pub wentry: C2RustUnnamed_16,
    pub sentry: C2RustUnnamed_15,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_15 {
    pub tqe_next: *mut winlink,
    pub tqe_prev: *mut *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_16 {
    pub tqe_next: *mut winlink,
    pub tqe_prev: *mut *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_17 {
    pub rbe_left: *mut winlink,
    pub rbe_right: *mut winlink,
    pub rbe_parent: *mut winlink,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window {
    pub id: u_int,
    pub latest: *mut libc::c_void,
    pub name: *mut i8,
    pub name_event: event,
    pub name_time: timeval,
    pub alerts_timer: event,
    pub offset_timer: event,
    pub activity_time: timeval,
    pub active: *mut window_pane,
    pub last_panes: window_panes,
    pub panes: window_panes,
    pub lastlayout: i32,
    pub layout_root: *mut layout_cell,
    pub saved_layout_root: *mut layout_cell,
    pub old_layout: *mut i8,
    pub sx: u_int,
    pub sy: u_int,
    pub manual_sx: u_int,
    pub manual_sy: u_int,
    pub xpixel: u_int,
    pub ypixel: u_int,
    pub new_sx: u_int,
    pub new_sy: u_int,
    pub new_xpixel: u_int,
    pub new_ypixel: u_int,
    pub fill_character: *mut utf8_data,
    pub flags: i32,
    pub alerts_queued: i32,
    pub alerts_entry: C2RustUnnamed_20,
    pub options: *mut options,
    pub references: u_int,
    pub winlinks: C2RustUnnamed_19,
    pub entry: C2RustUnnamed_18,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_18 {
    pub rbe_left: *mut window,
    pub rbe_right: *mut window,
    pub rbe_parent: *mut window,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_19 {
    pub tqh_first: *mut winlink,
    pub tqh_last: *mut *mut winlink,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_20 {
    pub tqe_next: *mut window,
    pub tqe_prev: *mut *mut window,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct layout_cell {
    pub type_0: layout_type,
    pub parent: *mut layout_cell,
    pub sx: u_int,
    pub sy: u_int,
    pub xoff: u_int,
    pub yoff: u_int,
    pub wp: *mut window_pane,
    pub cells: layout_cells,
    pub entry: C2RustUnnamed_21,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_21 {
    pub tqe_next: *mut layout_cell,
    pub tqe_prev: *mut *mut layout_cell,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct layout_cells {
    pub tqh_first: *mut layout_cell,
    pub tqh_last: *mut *mut layout_cell,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane {
    pub id: u_int,
    pub active_point: u_int,
    pub window: *mut window,
    pub options: *mut options,
    pub layout_cell: *mut layout_cell,
    pub saved_layout_cell: *mut layout_cell,
    pub sx: u_int,
    pub sy: u_int,
    pub xoff: u_int,
    pub yoff: u_int,
    pub flags: i32,
    pub sb_slider_y: u_int,
    pub sb_slider_h: u_int,
    pub argc: i32,
    pub argv: *mut *mut i8,
    pub shell: *mut i8,
    pub cwd: *mut i8,
    pub pid: pid_t,
    pub tty: [i8; 32],
    pub status: i32,
    pub dead_time: timeval,
    pub fd: i32,
    pub event: *mut bufferevent,
    pub offset: window_pane_offset,
    pub base_offset: size_t,
    pub resize_queue: window_pane_resizes,
    pub resize_timer: event,
    pub ictx: *mut input_ctx,
    pub cached_gc: grid_cell,
    pub cached_active_gc: grid_cell,
    pub palette: colour_palette,
    pub pipe_fd: i32,
    pub pipe_event: *mut bufferevent,
    pub pipe_offset: window_pane_offset,
    pub screen: *mut screen,
    pub base: screen,
    pub status_screen: screen,
    pub status_size: size_t,
    pub modes: C2RustUnnamed_25,
    pub searchstr: *mut i8,
    pub searchregex: i32,
    pub border_gc_set: i32,
    pub border_gc: grid_cell,
    pub control_bg: i32,
    pub control_fg: i32,
    pub scrollbar_style: style,
    pub entry: C2RustUnnamed_24,
    pub sentry: C2RustUnnamed_23,
    pub tree_entry: C2RustUnnamed_22,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_22 {
    pub rbe_left: *mut window_pane,
    pub rbe_right: *mut window_pane,
    pub rbe_parent: *mut window_pane,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_23 {
    pub tqe_next: *mut window_pane,
    pub tqe_prev: *mut *mut window_pane,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_24 {
    pub tqe_next: *mut window_pane,
    pub tqe_prev: *mut *mut window_pane,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct style {
    pub gc: grid_cell,
    pub ignore: i32,
    pub fill: i32,
    pub align: style_align,
    pub list: style_list,
    pub range_type: style_range_type,
    pub range_argument: u_int,
    pub range_string: [i8; 16],
    pub width: i32,
    pub pad: i32,
    pub default_type: style_default_type,
}
pub type style_default_type = u32;
pub const STYLE_DEFAULT_POP: style_default_type = 2;
pub const STYLE_DEFAULT_PUSH: style_default_type = 1;
pub const STYLE_DEFAULT_BASE: style_default_type = 0;
pub type style_range_type = u32;
pub const STYLE_RANGE_USER: style_range_type = 6;
pub const STYLE_RANGE_SESSION: style_range_type = 5;
pub const STYLE_RANGE_WINDOW: style_range_type = 4;
pub const STYLE_RANGE_PANE: style_range_type = 3;
pub const STYLE_RANGE_RIGHT: style_range_type = 2;
pub const STYLE_RANGE_LEFT: style_range_type = 1;
pub const STYLE_RANGE_NONE: style_range_type = 0;
pub type style_list = u32;
pub const STYLE_LIST_RIGHT_MARKER: style_list = 4;
pub const STYLE_LIST_LEFT_MARKER: style_list = 3;
pub const STYLE_LIST_FOCUS: style_list = 2;
pub const STYLE_LIST_ON: style_list = 1;
pub const STYLE_LIST_OFF: style_list = 0;
pub type style_align = u32;
pub const STYLE_ALIGN_ABSOLUTE_CENTRE: style_align = 4;
pub const STYLE_ALIGN_RIGHT: style_align = 3;
pub const STYLE_ALIGN_CENTRE: style_align = 2;
pub const STYLE_ALIGN_LEFT: style_align = 1;
pub const STYLE_ALIGN_DEFAULT: style_align = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_25 {
    pub tqh_first: *mut window_mode_entry,
    pub tqh_last: *mut *mut window_mode_entry,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_mode_entry {
    pub wp: *mut window_pane,
    pub swp: *mut window_pane,
    pub mode: *const window_mode,
    pub data: *mut libc::c_void,
    pub screen: *mut screen,
    pub prefix: u_int,
    pub entry: C2RustUnnamed_26,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_26 {
    pub tqe_next: *mut window_mode_entry,
    pub tqe_prev: *mut *mut window_mode_entry,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_mode {
    pub name: *const i8,
    pub default_format: *const i8,
    pub init: Option<
        unsafe extern "C" fn(*mut window_mode_entry, *mut cmd_find_state, *mut args) -> *mut screen,
    >,
    pub free: Option<unsafe extern "C" fn(*mut window_mode_entry) -> ()>,
    pub resize: Option<unsafe extern "C" fn(*mut window_mode_entry, u_int, u_int) -> ()>,
    pub update: Option<unsafe extern "C" fn(*mut window_mode_entry) -> ()>,
    pub key: Option<
        unsafe extern "C" fn(
            *mut window_mode_entry,
            *mut client,
            *mut session,
            *mut winlink,
            key_code,
            *mut mouse_event,
        ) -> (),
    >,
    pub key_table: Option<unsafe extern "C" fn(*mut window_mode_entry) -> *const i8>,
    pub command: Option<
        unsafe extern "C" fn(
            *mut window_mode_entry,
            *mut client,
            *mut session,
            *mut winlink,
            *mut args,
            *mut mouse_event,
        ) -> (),
    >,
    pub formats: Option<unsafe extern "C" fn(*mut window_mode_entry, *mut format_tree) -> ()>,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_tree {
    pub type_0: format_type,
    pub c: *mut client,
    pub s: *mut session,
    pub wl: *mut winlink,
    pub w: *mut window,
    pub wp: *mut window_pane,
    pub pb: *mut paste_buffer,
    pub item: *mut cmdq_item,
    pub client: *mut client,
    pub flags: i32,
    pub tag: u_int,
    pub m: mouse_event,
    pub tree: format_entry_tree,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_entry_tree {
    pub rbh_root: *mut format_entry,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_entry {
    pub key: *mut i8,
    pub value: *mut i8,
    pub time: time_t,
    pub cb: format_cb,
    pub entry: C2RustUnnamed_27,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_27 {
    pub rbe_left: *mut format_entry,
    pub rbe_right: *mut format_entry,
    pub rbe_parent: *mut format_entry,
    pub rbe_color: i32,
}
pub type format_cb = Option<unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void>;
pub type format_type = u32;
pub const FORMAT_TYPE_PANE: format_type = 3;
pub const FORMAT_TYPE_WINDOW: format_type = 2;
pub const FORMAT_TYPE_SESSION: format_type = 1;
pub const FORMAT_TYPE_UNKNOWN: format_type = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cmd_find_state {
    pub flags: i32,
    pub current: *mut cmd_find_state,
    pub s: *mut session,
    pub wl: *mut winlink,
    pub w: *mut window,
    pub wp: *mut window_pane,
    pub idx: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane_offset {
    pub used: size_t,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct colour_palette {
    pub fg: i32,
    pub bg: i32,
    pub palette: *mut i32,
    pub default_palette: *mut i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane_resizes {
    pub tqh_first: *mut window_pane_resize,
    pub tqh_last: *mut *mut window_pane_resize,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_pane_resize {
    pub sx: u_int,
    pub sy: u_int,
    pub osx: u_int,
    pub osy: u_int,
    pub entry: C2RustUnnamed_28,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_28 {
    pub tqe_next: *mut window_pane_resize,
    pub tqe_prev: *mut *mut window_pane_resize,
}
pub type layout_type = u32;
pub const LAYOUT_WINDOWPANE: layout_type = 2;
pub const LAYOUT_TOPBOTTOM: layout_type = 1;
pub const LAYOUT_LEFTRIGHT: layout_type = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct window_panes {
    pub tqh_first: *mut window_pane,
    pub tqh_last: *mut *mut window_pane,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct winlink_stack {
    pub tqh_first: *mut winlink,
    pub tqh_last: *mut *mut winlink,
}
pub type prompt_type = u32;
pub const PROMPT_TYPE_INVALID: prompt_type = 255;
pub const PROMPT_TYPE_WINDOW_TARGET: prompt_type = 3;
pub const PROMPT_TYPE_TARGET: prompt_type = 2;
pub const PROMPT_TYPE_SEARCH: prompt_type = 1;
pub const PROMPT_TYPE_COMMAND: prompt_type = 0;
pub type C2RustUnnamed_29 = u32;
pub const PROMPT_COMMAND: C2RustUnnamed_29 = 1;
pub const PROMPT_ENTRY: C2RustUnnamed_29 = 0;
pub type prompt_free_cb = Option<unsafe extern "C" fn(*mut libc::c_void) -> ()>;
pub type prompt_input_cb =
    Option<unsafe extern "C" fn(*mut client, *mut libc::c_void, *const i8, i32) -> i32>;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_table {
    pub name: *const i8,
    pub activity_time: timeval,
    pub key_bindings: key_bindings,
    pub default_key_bindings: key_bindings,
    pub references: u_int,
    pub entry: C2RustUnnamed_30,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_30 {
    pub rbe_left: *mut key_table,
    pub rbe_right: *mut key_table,
    pub rbe_parent: *mut key_table,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_bindings {
    pub rbh_root: *mut key_binding,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct key_binding {
    pub key: key_code,
    pub cmdlist: *mut cmd_list,
    pub note: *const i8,
    pub flags: i32,
    pub entry: C2RustUnnamed_31,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_31 {
    pub rbe_left: *mut key_binding,
    pub rbe_right: *mut key_binding,
    pub rbe_parent: *mut key_binding,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct cmd_list {
    pub references: i32,
    pub group: u_int,
    pub list: *mut cmds,
}
pub type C2RustUnnamed_32 = u32;
pub const CLIENT_EXIT_DETACH: C2RustUnnamed_32 = 2;
pub const CLIENT_EXIT_SHUTDOWN: C2RustUnnamed_32 = 1;
pub const CLIENT_EXIT_RETURN: C2RustUnnamed_32 = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct status_line {
    pub timer: event,
    pub screen: screen,
    pub active: *mut screen,
    pub references: i32,
    pub style: grid_cell,
    pub entries: [status_line_entry; 5],
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct status_line_entry {
    pub expanded: *mut i8,
    pub ranges: style_ranges,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct style_ranges {
    pub tqh_first: *mut style_range,
    pub tqh_last: *mut *mut style_range,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct style_range {
    pub type_0: style_range_type,
    pub argument: u_int,
    pub string: [i8; 16],
    pub start: u_int,
    pub end: u_int,
    pub entry: C2RustUnnamed_33,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_33 {
    pub tqe_next: *mut style_range,
    pub tqe_prev: *mut *mut style_range,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tty {
    pub client: *mut client,
    pub start_timer: event,
    pub clipboard_timer: event,
    pub last_requests: time_t,
    pub sx: u_int,
    pub sy: u_int,
    pub xpixel: u_int,
    pub ypixel: u_int,
    pub cx: u_int,
    pub cy: u_int,
    pub cstyle: screen_cursor_style,
    pub ccolour: i32,
    pub oflag: i32,
    pub oox: u_int,
    pub ooy: u_int,
    pub osx: u_int,
    pub osy: u_int,
    pub mode: i32,
    pub fg: i32,
    pub bg: i32,
    pub rlower: u_int,
    pub rupper: u_int,
    pub rleft: u_int,
    pub rright: u_int,
    pub event_in: event,
    pub in_0: *mut evbuffer,
    pub event_out: event,
    pub out: *mut evbuffer,
    pub timer: event,
    pub discarded: size_t,
    pub tio: termios,
    pub cell: grid_cell,
    pub last_cell: grid_cell,
    pub flags: i32,
    pub term: *mut tty_term,
    pub mouse_last_x: u_int,
    pub mouse_last_y: u_int,
    pub mouse_last_b: u_int,
    pub mouse_drag_flag: i32,
    pub mouse_scrolling_flag: i32,
    pub mouse_slider_mpos: i32,
    pub mouse_drag_update: Option<unsafe extern "C" fn(*mut client, *mut mouse_event) -> ()>,
    pub mouse_drag_release: Option<unsafe extern "C" fn(*mut client, *mut mouse_event) -> ()>,
    pub key_timer: event,
    pub key_tree: *mut tty_key,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct tty_term {
    pub name: *mut i8,
    pub tty: *mut tty,
    pub features: i32,
    pub acs: [[i8; 2]; 256],
    pub codes: *mut tty_code,
    pub flags: i32,
    pub entry: C2RustUnnamed_34,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_34 {
    pub le_next: *mut tty_term,
    pub le_prev: *mut *mut tty_term,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_job_tree {
    pub rbh_root: *mut format_job,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_job {
    pub client: *mut client,
    pub tag: u_int,
    pub cmd: *const i8,
    pub expanded: *const i8,
    pub last: time_t,
    pub out: *mut i8,
    pub updated: i32,
    pub job: *mut job,
    pub status: i32,
    pub entry: C2RustUnnamed_35,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_35 {
    pub rbe_left: *mut format_job,
    pub rbe_right: *mut format_job,
    pub rbe_parent: *mut format_job,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_windows {
    pub rbh_root: *mut client_window,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct client_window {
    pub window: u_int,
    pub pane: *mut window_pane,
    pub sx: u_int,
    pub sy: u_int,
    pub entry: C2RustUnnamed_36,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_36 {
    pub rbe_left: *mut client_window,
    pub rbe_right: *mut client_window,
    pub rbe_parent: *mut client_window,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct environ_entry {
    pub name: *mut i8,
    pub value: *mut i8,
    pub flags: i32,
    pub entry: C2RustUnnamed_37,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_37 {
    pub rbe_left: *mut environ_entry,
    pub rbe_right: *mut environ_entry,
    pub rbe_parent: *mut environ_entry,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct session_group {
    pub name: *const i8,
    pub sessions: C2RustUnnamed_39,
    pub entry: C2RustUnnamed_38,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_38 {
    pub rbe_left: *mut session_group,
    pub rbe_right: *mut session_group,
    pub rbe_parent: *mut session_group,
    pub rbe_color: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct C2RustUnnamed_39 {
    pub tqh_first: *mut session,
    pub tqh_last: *mut *mut session,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct sessions {
    pub rbh_root: *mut session,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct clients {
    pub tqh_first: *mut client,
    pub tqh_last: *mut *mut client,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_modifier {
    pub modifier: [i8; 3],
    pub size: u_int,
    pub argv: *mut *mut i8,
    pub argc: i32,
}
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_table_entry {
    pub key: *const i8,
    pub type_0: format_table_type,
    pub cb: format_cb,
}
pub type format_table_type = u32;
pub const FORMAT_TABLE_TIME: format_table_type = 1;
pub const FORMAT_TABLE_STRING: format_table_type = 0;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct format_expand_state {
    pub ft: *mut format_tree,
    pub loop_0: u_int,
    pub time: time_t,
    pub tm: tm,
    pub flags: i32,
}
pub const LESS_THAN_EQUAL: C2RustUnnamed_40 = 10;
pub const LESS_THAN: C2RustUnnamed_40 = 9;
pub const GREATER_THAN_EQUAL: C2RustUnnamed_40 = 8;
pub const GREATER_THAN: C2RustUnnamed_40 = 7;
pub const NOT_EQUAL: C2RustUnnamed_40 = 6;
pub const EQUAL: C2RustUnnamed_40 = 5;
pub const MODULUS: C2RustUnnamed_40 = 4;
pub const DIVIDE: C2RustUnnamed_40 = 3;
pub const MULTIPLY: C2RustUnnamed_40 = 2;
pub const SUBTRACT: C2RustUnnamed_40 = 1;
pub const ADD: C2RustUnnamed_40 = 0;
pub type C2RustUnnamed_40 = u32;
pub type job_free_cb = Option<unsafe extern "C" fn(*mut libc::c_void) -> ()>;
pub type job_complete_cb = Option<unsafe extern "C" fn(*mut job) -> ()>;
pub type job_update_cb = Option<unsafe extern "C" fn(*mut job) -> ()>;
static mut format_jobs: format_job_tree = {
    let mut init = format_job_tree {
        rbh_root: 0 as *const format_job as *mut format_job,
    };
    init
};
extern "C" fn format_job_tree_RB_INSERT(
    mut head: *mut format_job_tree,
    mut elm: *mut format_job,
) -> *mut format_job {
    let mut tmp: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut parent: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut comp: i32 = 0 as i32;
    tmp = unsafe { (*head).rbh_root };
    while !tmp.is_null() {
        parent = tmp;
        comp = format_job_cmp(elm, parent);
        if comp < 0 as i32 {
            tmp = unsafe { (*tmp).entry.rbe_left };
        } else if comp > 0 as i32 {
            tmp = unsafe { (*tmp).entry.rbe_right };
        } else {
            return tmp;
        }
    }
    (unsafe { (*elm).entry.rbe_parent = parent });
    (unsafe { (*elm).entry.rbe_right = std::ptr::null_mut::<format_job>() });
    (unsafe { (*elm).entry.rbe_left = (*elm).entry.rbe_right });
    (unsafe { (*elm).entry.rbe_color = 1 as i32 });
    if !parent.is_null() {
        if comp < 0 as i32 {
            (unsafe { (*parent).entry.rbe_left = elm });
        } else {
            (unsafe { (*parent).entry.rbe_right = elm });
        }
    } else {
        (unsafe { (*head).rbh_root = elm });
    }
    format_job_tree_RB_INSERT_COLOR(head, elm);
    return std::ptr::null_mut::<format_job>();
}
extern "C" fn format_job_tree_RB_REMOVE(
    mut head: *mut format_job_tree,
    mut elm: *mut format_job,
) -> *mut format_job {
    let mut current_block: u64;
    let mut child: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut parent: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut old: *mut format_job = elm;
    let mut color: i32 = 0;
    if (unsafe { (*elm).entry.rbe_left }).is_null() {
        child = unsafe { (*elm).entry.rbe_right };
        current_block = 7245201122033322888;
    } else if (unsafe { (*elm).entry.rbe_right }).is_null() {
        child = unsafe { (*elm).entry.rbe_left };
        current_block = 7245201122033322888;
    } else {
        let mut left: *mut format_job = std::ptr::null_mut::<format_job>();
        elm = unsafe { (*elm).entry.rbe_right };
        loop {
            left = unsafe { (*elm).entry.rbe_left };
            if left.is_null() {
                break;
            }
            elm = left;
        }
        child = unsafe { (*elm).entry.rbe_right };
        parent = unsafe { (*elm).entry.rbe_parent };
        color = unsafe { (*elm).entry.rbe_color };
        if !child.is_null() {
            (unsafe { (*child).entry.rbe_parent = parent });
        }
        if !parent.is_null() {
            if (unsafe { (*parent).entry.rbe_left }) == elm {
                (unsafe { (*parent).entry.rbe_left = child });
            } else {
                (unsafe { (*parent).entry.rbe_right = child });
            }
        } else {
            (unsafe { (*head).rbh_root = child });
        }
        if (unsafe { (*elm).entry.rbe_parent }) == old {
            parent = elm;
        }
        (unsafe { (*elm).entry = (*old).entry });
        if !(unsafe { (*old).entry.rbe_parent }).is_null() {
            if (unsafe { (*(*old).entry.rbe_parent).entry.rbe_left }) == old {
                (unsafe { (*(*old).entry.rbe_parent).entry.rbe_left = elm });
            } else {
                (unsafe { (*(*old).entry.rbe_parent).entry.rbe_right = elm });
            }
        } else {
            (unsafe { (*head).rbh_root = elm });
        }
        (unsafe { (*(*old).entry.rbe_left).entry.rbe_parent = elm });
        if !(unsafe { (*old).entry.rbe_right }).is_null() {
            (unsafe { (*(*old).entry.rbe_right).entry.rbe_parent = elm });
        }
        if !parent.is_null() {
            left = parent;
            loop {
                left = unsafe { (*left).entry.rbe_parent };
                if left.is_null() {
                    break;
                }
            }
        }
        current_block = 13966504069422014721;
    }
    match current_block {
        7245201122033322888 => {
            parent = unsafe { (*elm).entry.rbe_parent };
            color = unsafe { (*elm).entry.rbe_color };
            if !child.is_null() {
                (unsafe { (*child).entry.rbe_parent = parent });
            }
            if !parent.is_null() {
                if (unsafe { (*parent).entry.rbe_left }) == elm {
                    (unsafe { (*parent).entry.rbe_left = child });
                } else {
                    (unsafe { (*parent).entry.rbe_right = child });
                }
            } else {
                (unsafe { (*head).rbh_root = child });
            }
        }
        _ => {}
    }
    if color == 0 as i32 {
        format_job_tree_RB_REMOVE_COLOR(head, parent, child);
    }
    return old;
}
extern "C" fn format_job_tree_RB_INSERT_COLOR(
    mut head: *mut format_job_tree,
    mut elm: *mut format_job,
) {
    let mut parent: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut gparent: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut tmp: *mut format_job = std::ptr::null_mut::<format_job>();
    loop {
        parent = unsafe { (*elm).entry.rbe_parent };
        if parent.is_null() || (unsafe { (*parent).entry.rbe_color }) != 1 as i32 {
            break;
        }
        gparent = unsafe { (*parent).entry.rbe_parent };
        if parent == (unsafe { (*gparent).entry.rbe_left }) {
            tmp = unsafe { (*gparent).entry.rbe_right };
            if !tmp.is_null() && (unsafe { (*tmp).entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).entry.rbe_color = 1 as i32 });
                elm = gparent;
            } else {
                if (unsafe { (*parent).entry.rbe_right }) == elm {
                    tmp = unsafe { (*parent).entry.rbe_right };
                    (unsafe { (*parent).entry.rbe_right = (*tmp).entry.rbe_left });
                    if !(unsafe { (*parent).entry.rbe_right }).is_null() {
                        (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_parent = parent });
                    }
                    (unsafe { (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent });
                    if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                        if parent == (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left }) {
                            (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left = tmp });
                        } else {
                            (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_right = tmp });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = tmp });
                    }
                    (unsafe { (*tmp).entry.rbe_left = parent });
                    (unsafe { (*parent).entry.rbe_parent = tmp });
                    let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (unsafe { (*parent).entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*gparent).entry.rbe_left };
                (unsafe { (*gparent).entry.rbe_left = (*tmp).entry.rbe_right });
                if !(unsafe { (*gparent).entry.rbe_left }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_parent = gparent });
                }
                (unsafe { (*tmp).entry.rbe_parent = (*gparent).entry.rbe_parent });
                if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                    if gparent == (unsafe { (*(*gparent).entry.rbe_parent).entry.rbe_left }) {
                        (unsafe { (*(*gparent).entry.rbe_parent).entry.rbe_left = tmp });
                    } else {
                        (unsafe { (*(*gparent).entry.rbe_parent).entry.rbe_right = tmp });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).entry.rbe_right = gparent });
                (unsafe { (*gparent).entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
            }
        } else {
            tmp = unsafe { (*gparent).entry.rbe_left };
            if !tmp.is_null() && (unsafe { (*tmp).entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).entry.rbe_color = 1 as i32 });
                elm = gparent;
            } else {
                if (unsafe { (*parent).entry.rbe_left }) == elm {
                    tmp = unsafe { (*parent).entry.rbe_left };
                    (unsafe { (*parent).entry.rbe_left = (*tmp).entry.rbe_right });
                    if !(unsafe { (*parent).entry.rbe_left }).is_null() {
                        (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_parent = parent });
                    }
                    (unsafe { (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent });
                    if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                        if parent == (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left }) {
                            (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left = tmp });
                        } else {
                            (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_right = tmp });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = tmp });
                    }
                    (unsafe { (*tmp).entry.rbe_right = parent });
                    (unsafe { (*parent).entry.rbe_parent = tmp });
                    let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (unsafe { (*parent).entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*gparent).entry.rbe_right };
                (unsafe { (*gparent).entry.rbe_right = (*tmp).entry.rbe_left });
                if !(unsafe { (*gparent).entry.rbe_right }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_parent = gparent });
                }
                (unsafe { (*tmp).entry.rbe_parent = (*gparent).entry.rbe_parent });
                if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                    if gparent == (unsafe { (*(*gparent).entry.rbe_parent).entry.rbe_left }) {
                        (unsafe { (*(*gparent).entry.rbe_parent).entry.rbe_left = tmp });
                    } else {
                        (unsafe { (*(*gparent).entry.rbe_parent).entry.rbe_right = tmp });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).entry.rbe_left = gparent });
                (unsafe { (*gparent).entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
            }
        }
    }
    (unsafe { (*(*head).rbh_root).entry.rbe_color = 0 as i32 });
}
extern "C" fn format_job_tree_RB_FIND(
    mut head: *mut format_job_tree,
    mut elm: *mut format_job,
) -> *mut format_job {
    let mut tmp: *mut format_job = unsafe { (*head).rbh_root };
    let mut comp: i32 = 0;
    while !tmp.is_null() {
        comp = format_job_cmp(elm, tmp);
        if comp < 0 as i32 {
            tmp = unsafe { (*tmp).entry.rbe_left };
        } else if comp > 0 as i32 {
            tmp = unsafe { (*tmp).entry.rbe_right };
        } else {
            return tmp;
        }
    }
    return std::ptr::null_mut::<format_job>();
}
extern "C" fn format_job_tree_RB_REMOVE_COLOR(
    mut head: *mut format_job_tree,
    mut parent: *mut format_job,
    mut elm: *mut format_job,
) {
    let mut tmp: *mut format_job = std::ptr::null_mut::<format_job>();
    while (elm.is_null() || (unsafe { (*elm).entry.rbe_color }) == 0 as i32)
        && elm != (unsafe { (*head).rbh_root })
    {
        if (unsafe { (*parent).entry.rbe_left }) == elm {
            tmp = unsafe { (*parent).entry.rbe_right };
            if (unsafe { (*tmp).entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*parent).entry.rbe_right };
                (unsafe { (*parent).entry.rbe_right = (*tmp).entry.rbe_left });
                if !(unsafe { (*parent).entry.rbe_right }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_parent = parent });
                }
                (unsafe { (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent });
                if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                    if parent == (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left }) {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left = tmp });
                    } else {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_right = tmp });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).entry.rbe_left = parent });
                (unsafe { (*parent).entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
                tmp = unsafe { (*parent).entry.rbe_right };
            }
            if ((unsafe { (*tmp).entry.rbe_left }).is_null()
                || (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_color }) == 0 as i32)
                && ((unsafe { (*tmp).entry.rbe_right }).is_null()
                    || (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_color }) == 0 as i32)
            {
                (unsafe { (*tmp).entry.rbe_color = 1 as i32 });
                elm = parent;
                parent = unsafe { (*elm).entry.rbe_parent };
            } else {
                if (unsafe { (*tmp).entry.rbe_right }).is_null()
                    || (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_color }) == 0 as i32
                {
                    let mut oleft: *mut format_job = std::ptr::null_mut::<format_job>();
                    oleft = unsafe { (*tmp).entry.rbe_left };
                    if !oleft.is_null() {
                        (unsafe { (*oleft).entry.rbe_color = 0 as i32 });
                    }
                    (unsafe { (*tmp).entry.rbe_color = 1 as i32 });
                    oleft = unsafe { (*tmp).entry.rbe_left };
                    (unsafe { (*tmp).entry.rbe_left = (*oleft).entry.rbe_right });
                    if !(unsafe { (*tmp).entry.rbe_left }).is_null() {
                        (unsafe { (*(*oleft).entry.rbe_right).entry.rbe_parent = tmp });
                    }
                    (unsafe { (*oleft).entry.rbe_parent = (*tmp).entry.rbe_parent });
                    if !(unsafe { (*oleft).entry.rbe_parent }).is_null() {
                        if tmp == (unsafe { (*(*tmp).entry.rbe_parent).entry.rbe_left }) {
                            (unsafe { (*(*tmp).entry.rbe_parent).entry.rbe_left = oleft });
                        } else {
                            (unsafe { (*(*tmp).entry.rbe_parent).entry.rbe_right = oleft });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = oleft });
                    }
                    (unsafe { (*oleft).entry.rbe_right = tmp });
                    (unsafe { (*tmp).entry.rbe_parent = oleft });
                    let _ = !(unsafe { (*oleft).entry.rbe_parent }).is_null();
                    tmp = unsafe { (*parent).entry.rbe_right };
                }
                (unsafe { (*tmp).entry.rbe_color = (*parent).entry.rbe_color });
                (unsafe { (*parent).entry.rbe_color = 0 as i32 });
                if !(unsafe { (*tmp).entry.rbe_right }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_color = 0 as i32 });
                }
                tmp = unsafe { (*parent).entry.rbe_right };
                (unsafe { (*parent).entry.rbe_right = (*tmp).entry.rbe_left });
                if !(unsafe { (*parent).entry.rbe_right }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_parent = parent });
                }
                (unsafe { (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent });
                if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                    if parent == (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left }) {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left = tmp });
                    } else {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_right = tmp });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).entry.rbe_left = parent });
                (unsafe { (*parent).entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
                elm = unsafe { (*head).rbh_root };
                break;
            }
        } else {
            tmp = unsafe { (*parent).entry.rbe_left };
            if (unsafe { (*tmp).entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*parent).entry.rbe_left };
                (unsafe { (*parent).entry.rbe_left = (*tmp).entry.rbe_right });
                if !(unsafe { (*parent).entry.rbe_left }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_parent = parent });
                }
                (unsafe { (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent });
                if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                    if parent == (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left }) {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left = tmp });
                    } else {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_right = tmp });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).entry.rbe_right = parent });
                (unsafe { (*parent).entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
                tmp = unsafe { (*parent).entry.rbe_left };
            }
            if ((unsafe { (*tmp).entry.rbe_left }).is_null()
                || (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_color }) == 0 as i32)
                && ((unsafe { (*tmp).entry.rbe_right }).is_null()
                    || (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_color }) == 0 as i32)
            {
                (unsafe { (*tmp).entry.rbe_color = 1 as i32 });
                elm = parent;
                parent = unsafe { (*elm).entry.rbe_parent };
            } else {
                if (unsafe { (*tmp).entry.rbe_left }).is_null()
                    || (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_color }) == 0 as i32
                {
                    let mut oright: *mut format_job = std::ptr::null_mut::<format_job>();
                    oright = unsafe { (*tmp).entry.rbe_right };
                    if !oright.is_null() {
                        (unsafe { (*oright).entry.rbe_color = 0 as i32 });
                    }
                    (unsafe { (*tmp).entry.rbe_color = 1 as i32 });
                    oright = unsafe { (*tmp).entry.rbe_right };
                    (unsafe { (*tmp).entry.rbe_right = (*oright).entry.rbe_left });
                    if !(unsafe { (*tmp).entry.rbe_right }).is_null() {
                        (unsafe { (*(*oright).entry.rbe_left).entry.rbe_parent = tmp });
                    }
                    (unsafe { (*oright).entry.rbe_parent = (*tmp).entry.rbe_parent });
                    if !(unsafe { (*oright).entry.rbe_parent }).is_null() {
                        if tmp == (unsafe { (*(*tmp).entry.rbe_parent).entry.rbe_left }) {
                            (unsafe { (*(*tmp).entry.rbe_parent).entry.rbe_left = oright });
                        } else {
                            (unsafe { (*(*tmp).entry.rbe_parent).entry.rbe_right = oright });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = oright });
                    }
                    (unsafe { (*oright).entry.rbe_left = tmp });
                    (unsafe { (*tmp).entry.rbe_parent = oright });
                    let _ = !(unsafe { (*oright).entry.rbe_parent }).is_null();
                    tmp = unsafe { (*parent).entry.rbe_left };
                }
                (unsafe { (*tmp).entry.rbe_color = (*parent).entry.rbe_color });
                (unsafe { (*parent).entry.rbe_color = 0 as i32 });
                if !(unsafe { (*tmp).entry.rbe_left }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_color = 0 as i32 });
                }
                tmp = unsafe { (*parent).entry.rbe_left };
                (unsafe { (*parent).entry.rbe_left = (*tmp).entry.rbe_right });
                if !(unsafe { (*parent).entry.rbe_left }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_parent = parent });
                }
                (unsafe { (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent });
                if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                    if parent == (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left }) {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left = tmp });
                    } else {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_right = tmp });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).entry.rbe_right = parent });
                (unsafe { (*parent).entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
                elm = unsafe { (*head).rbh_root };
                break;
            }
        }
    }
    if !elm.is_null() {
        (unsafe { (*elm).entry.rbe_color = 0 as i32 });
    }
}
extern "C" fn format_job_tree_RB_NEXT(mut elm: *mut format_job) -> *mut format_job {
    if !(unsafe { (*elm).entry.rbe_right }).is_null() {
        elm = unsafe { (*elm).entry.rbe_right };
        while !(unsafe { (*elm).entry.rbe_left }).is_null() {
            elm = unsafe { (*elm).entry.rbe_left };
        }
    } else if !(unsafe { (*elm).entry.rbe_parent }).is_null()
        && elm == (unsafe { (*(*elm).entry.rbe_parent).entry.rbe_left })
    {
        elm = unsafe { (*elm).entry.rbe_parent };
    } else {
        while !(unsafe { (*elm).entry.rbe_parent }).is_null()
            && elm == (unsafe { (*(*elm).entry.rbe_parent).entry.rbe_right })
        {
            elm = unsafe { (*elm).entry.rbe_parent };
        }
        elm = unsafe { (*elm).entry.rbe_parent };
    }
    return elm;
}
extern "C" fn format_job_tree_RB_MINMAX(
    mut head: *mut format_job_tree,
    mut val: i32,
) -> *mut format_job {
    let mut tmp: *mut format_job = unsafe { (*head).rbh_root };
    let mut parent: *mut format_job = std::ptr::null_mut::<format_job>();
    while !tmp.is_null() {
        parent = tmp;
        if val < 0 as i32 {
            tmp = unsafe { (*tmp).entry.rbe_left };
        } else {
            tmp = unsafe { (*tmp).entry.rbe_right };
        }
    }
    return parent;
}
extern "C" fn format_job_cmp(mut fj1: *mut format_job, mut fj2: *mut format_job) -> i32 {
    if (unsafe { (*fj1).tag }) < (unsafe { (*fj2).tag }) {
        return -(1 as i32);
    }
    if (unsafe { (*fj1).tag }) > (unsafe { (*fj2).tag }) {
        return 1 as i32;
    }
    return unsafe { strcmp((*fj1).cmd, (*fj2).cmd) };
}
extern "C" fn format_entry_tree_RB_REMOVE(
    mut head: *mut format_entry_tree,
    mut elm: *mut format_entry,
) -> *mut format_entry {
    let mut current_block: u64;
    let mut child: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut parent: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut old: *mut format_entry = elm;
    let mut color: i32 = 0;
    if (unsafe { (*elm).entry.rbe_left }).is_null() {
        child = unsafe { (*elm).entry.rbe_right };
        current_block = 7245201122033322888;
    } else if (unsafe { (*elm).entry.rbe_right }).is_null() {
        child = unsafe { (*elm).entry.rbe_left };
        current_block = 7245201122033322888;
    } else {
        let mut left: *mut format_entry = std::ptr::null_mut::<format_entry>();
        elm = unsafe { (*elm).entry.rbe_right };
        loop {
            left = unsafe { (*elm).entry.rbe_left };
            if left.is_null() {
                break;
            }
            elm = left;
        }
        child = unsafe { (*elm).entry.rbe_right };
        parent = unsafe { (*elm).entry.rbe_parent };
        color = unsafe { (*elm).entry.rbe_color };
        if !child.is_null() {
            (unsafe { (*child).entry.rbe_parent = parent });
        }
        if !parent.is_null() {
            if (unsafe { (*parent).entry.rbe_left }) == elm {
                (unsafe { (*parent).entry.rbe_left = child });
            } else {
                (unsafe { (*parent).entry.rbe_right = child });
            }
        } else {
            (unsafe { (*head).rbh_root = child });
        }
        if (unsafe { (*elm).entry.rbe_parent }) == old {
            parent = elm;
        }
        (unsafe { (*elm).entry = (*old).entry });
        if !(unsafe { (*old).entry.rbe_parent }).is_null() {
            if (unsafe { (*(*old).entry.rbe_parent).entry.rbe_left }) == old {
                (unsafe { (*(*old).entry.rbe_parent).entry.rbe_left = elm });
            } else {
                (unsafe { (*(*old).entry.rbe_parent).entry.rbe_right = elm });
            }
        } else {
            (unsafe { (*head).rbh_root = elm });
        }
        (unsafe { (*(*old).entry.rbe_left).entry.rbe_parent = elm });
        if !(unsafe { (*old).entry.rbe_right }).is_null() {
            (unsafe { (*(*old).entry.rbe_right).entry.rbe_parent = elm });
        }
        if !parent.is_null() {
            left = parent;
            loop {
                left = unsafe { (*left).entry.rbe_parent };
                if left.is_null() {
                    break;
                }
            }
        }
        current_block = 17454932169446422658;
    }
    match current_block {
        7245201122033322888 => {
            parent = unsafe { (*elm).entry.rbe_parent };
            color = unsafe { (*elm).entry.rbe_color };
            if !child.is_null() {
                (unsafe { (*child).entry.rbe_parent = parent });
            }
            if !parent.is_null() {
                if (unsafe { (*parent).entry.rbe_left }) == elm {
                    (unsafe { (*parent).entry.rbe_left = child });
                } else {
                    (unsafe { (*parent).entry.rbe_right = child });
                }
            } else {
                (unsafe { (*head).rbh_root = child });
            }
        }
        _ => {}
    }
    if color == 0 as i32 {
        format_entry_tree_RB_REMOVE_COLOR(head, parent, child);
    }
    return old;
}
extern "C" fn format_entry_tree_RB_FIND(
    mut head: *mut format_entry_tree,
    mut elm: *mut format_entry,
) -> *mut format_entry {
    let mut tmp: *mut format_entry = unsafe { (*head).rbh_root };
    let mut comp: i32 = 0;
    while !tmp.is_null() {
        comp = format_entry_cmp(elm, tmp);
        if comp < 0 as i32 {
            tmp = unsafe { (*tmp).entry.rbe_left };
        } else if comp > 0 as i32 {
            tmp = unsafe { (*tmp).entry.rbe_right };
        } else {
            return tmp;
        }
    }
    return std::ptr::null_mut::<format_entry>();
}
extern "C" fn format_entry_tree_RB_MINMAX(
    mut head: *mut format_entry_tree,
    mut val: i32,
) -> *mut format_entry {
    let mut tmp: *mut format_entry = unsafe { (*head).rbh_root };
    let mut parent: *mut format_entry = std::ptr::null_mut::<format_entry>();
    while !tmp.is_null() {
        parent = tmp;
        if val < 0 as i32 {
            tmp = unsafe { (*tmp).entry.rbe_left };
        } else {
            tmp = unsafe { (*tmp).entry.rbe_right };
        }
    }
    return parent;
}
extern "C" fn format_entry_tree_RB_INSERT_COLOR(
    mut head: *mut format_entry_tree,
    mut elm: *mut format_entry,
) {
    let mut parent: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut gparent: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut tmp: *mut format_entry = std::ptr::null_mut::<format_entry>();
    loop {
        parent = unsafe { (*elm).entry.rbe_parent };
        if parent.is_null() || (unsafe { (*parent).entry.rbe_color }) != 1 as i32 {
            break;
        }
        gparent = unsafe { (*parent).entry.rbe_parent };
        if parent == (unsafe { (*gparent).entry.rbe_left }) {
            tmp = unsafe { (*gparent).entry.rbe_right };
            if !tmp.is_null() && (unsafe { (*tmp).entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).entry.rbe_color = 1 as i32 });
                elm = gparent;
            } else {
                if (unsafe { (*parent).entry.rbe_right }) == elm {
                    tmp = unsafe { (*parent).entry.rbe_right };
                    (unsafe { (*parent).entry.rbe_right = (*tmp).entry.rbe_left });
                    if !(unsafe { (*parent).entry.rbe_right }).is_null() {
                        (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_parent = parent });
                    }
                    (unsafe { (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent });
                    if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                        if parent == (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left }) {
                            (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left = tmp });
                        } else {
                            (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_right = tmp });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = tmp });
                    }
                    (unsafe { (*tmp).entry.rbe_left = parent });
                    (unsafe { (*parent).entry.rbe_parent = tmp });
                    let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (unsafe { (*parent).entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*gparent).entry.rbe_left };
                (unsafe { (*gparent).entry.rbe_left = (*tmp).entry.rbe_right });
                if !(unsafe { (*gparent).entry.rbe_left }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_parent = gparent });
                }
                (unsafe { (*tmp).entry.rbe_parent = (*gparent).entry.rbe_parent });
                if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                    if gparent == (unsafe { (*(*gparent).entry.rbe_parent).entry.rbe_left }) {
                        (unsafe { (*(*gparent).entry.rbe_parent).entry.rbe_left = tmp });
                    } else {
                        (unsafe { (*(*gparent).entry.rbe_parent).entry.rbe_right = tmp });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).entry.rbe_right = gparent });
                (unsafe { (*gparent).entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
            }
        } else {
            tmp = unsafe { (*gparent).entry.rbe_left };
            if !tmp.is_null() && (unsafe { (*tmp).entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).entry.rbe_color = 1 as i32 });
                elm = gparent;
            } else {
                if (unsafe { (*parent).entry.rbe_left }) == elm {
                    tmp = unsafe { (*parent).entry.rbe_left };
                    (unsafe { (*parent).entry.rbe_left = (*tmp).entry.rbe_right });
                    if !(unsafe { (*parent).entry.rbe_left }).is_null() {
                        (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_parent = parent });
                    }
                    (unsafe { (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent });
                    if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                        if parent == (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left }) {
                            (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left = tmp });
                        } else {
                            (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_right = tmp });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = tmp });
                    }
                    (unsafe { (*tmp).entry.rbe_right = parent });
                    (unsafe { (*parent).entry.rbe_parent = tmp });
                    let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
                    tmp = parent;
                    parent = elm;
                    elm = tmp;
                }
                (unsafe { (*parent).entry.rbe_color = 0 as i32 });
                (unsafe { (*gparent).entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*gparent).entry.rbe_right };
                (unsafe { (*gparent).entry.rbe_right = (*tmp).entry.rbe_left });
                if !(unsafe { (*gparent).entry.rbe_right }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_parent = gparent });
                }
                (unsafe { (*tmp).entry.rbe_parent = (*gparent).entry.rbe_parent });
                if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                    if gparent == (unsafe { (*(*gparent).entry.rbe_parent).entry.rbe_left }) {
                        (unsafe { (*(*gparent).entry.rbe_parent).entry.rbe_left = tmp });
                    } else {
                        (unsafe { (*(*gparent).entry.rbe_parent).entry.rbe_right = tmp });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).entry.rbe_left = gparent });
                (unsafe { (*gparent).entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
            }
        }
    }
    (unsafe { (*(*head).rbh_root).entry.rbe_color = 0 as i32 });
}
extern "C" fn format_entry_tree_RB_INSERT(
    mut head: *mut format_entry_tree,
    mut elm: *mut format_entry,
) -> *mut format_entry {
    let mut tmp: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut parent: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut comp: i32 = 0 as i32;
    tmp = unsafe { (*head).rbh_root };
    while !tmp.is_null() {
        parent = tmp;
        comp = format_entry_cmp(elm, parent);
        if comp < 0 as i32 {
            tmp = unsafe { (*tmp).entry.rbe_left };
        } else if comp > 0 as i32 {
            tmp = unsafe { (*tmp).entry.rbe_right };
        } else {
            return tmp;
        }
    }
    (unsafe { (*elm).entry.rbe_parent = parent });
    (unsafe { (*elm).entry.rbe_right = std::ptr::null_mut::<format_entry>() });
    (unsafe { (*elm).entry.rbe_left = (*elm).entry.rbe_right });
    (unsafe { (*elm).entry.rbe_color = 1 as i32 });
    if !parent.is_null() {
        if comp < 0 as i32 {
            (unsafe { (*parent).entry.rbe_left = elm });
        } else {
            (unsafe { (*parent).entry.rbe_right = elm });
        }
    } else {
        (unsafe { (*head).rbh_root = elm });
    }
    format_entry_tree_RB_INSERT_COLOR(head, elm);
    return std::ptr::null_mut::<format_entry>();
}
extern "C" fn format_entry_tree_RB_REMOVE_COLOR(
    mut head: *mut format_entry_tree,
    mut parent: *mut format_entry,
    mut elm: *mut format_entry,
) {
    let mut tmp: *mut format_entry = std::ptr::null_mut::<format_entry>();
    while (elm.is_null() || (unsafe { (*elm).entry.rbe_color }) == 0 as i32)
        && elm != (unsafe { (*head).rbh_root })
    {
        if (unsafe { (*parent).entry.rbe_left }) == elm {
            tmp = unsafe { (*parent).entry.rbe_right };
            if (unsafe { (*tmp).entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*parent).entry.rbe_right };
                (unsafe { (*parent).entry.rbe_right = (*tmp).entry.rbe_left });
                if !(unsafe { (*parent).entry.rbe_right }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_parent = parent });
                }
                (unsafe { (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent });
                if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                    if parent == (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left }) {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left = tmp });
                    } else {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_right = tmp });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).entry.rbe_left = parent });
                (unsafe { (*parent).entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
                tmp = unsafe { (*parent).entry.rbe_right };
            }
            if ((unsafe { (*tmp).entry.rbe_left }).is_null()
                || (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_color }) == 0 as i32)
                && ((unsafe { (*tmp).entry.rbe_right }).is_null()
                    || (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_color }) == 0 as i32)
            {
                (unsafe { (*tmp).entry.rbe_color = 1 as i32 });
                elm = parent;
                parent = unsafe { (*elm).entry.rbe_parent };
            } else {
                if (unsafe { (*tmp).entry.rbe_right }).is_null()
                    || (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_color }) == 0 as i32
                {
                    let mut oleft: *mut format_entry = std::ptr::null_mut::<format_entry>();
                    oleft = unsafe { (*tmp).entry.rbe_left };
                    if !oleft.is_null() {
                        (unsafe { (*oleft).entry.rbe_color = 0 as i32 });
                    }
                    (unsafe { (*tmp).entry.rbe_color = 1 as i32 });
                    oleft = unsafe { (*tmp).entry.rbe_left };
                    (unsafe { (*tmp).entry.rbe_left = (*oleft).entry.rbe_right });
                    if !(unsafe { (*tmp).entry.rbe_left }).is_null() {
                        (unsafe { (*(*oleft).entry.rbe_right).entry.rbe_parent = tmp });
                    }
                    (unsafe { (*oleft).entry.rbe_parent = (*tmp).entry.rbe_parent });
                    if !(unsafe { (*oleft).entry.rbe_parent }).is_null() {
                        if tmp == (unsafe { (*(*tmp).entry.rbe_parent).entry.rbe_left }) {
                            (unsafe { (*(*tmp).entry.rbe_parent).entry.rbe_left = oleft });
                        } else {
                            (unsafe { (*(*tmp).entry.rbe_parent).entry.rbe_right = oleft });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = oleft });
                    }
                    (unsafe { (*oleft).entry.rbe_right = tmp });
                    (unsafe { (*tmp).entry.rbe_parent = oleft });
                    let _ = !(unsafe { (*oleft).entry.rbe_parent }).is_null();
                    tmp = unsafe { (*parent).entry.rbe_right };
                }
                (unsafe { (*tmp).entry.rbe_color = (*parent).entry.rbe_color });
                (unsafe { (*parent).entry.rbe_color = 0 as i32 });
                if !(unsafe { (*tmp).entry.rbe_right }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_color = 0 as i32 });
                }
                tmp = unsafe { (*parent).entry.rbe_right };
                (unsafe { (*parent).entry.rbe_right = (*tmp).entry.rbe_left });
                if !(unsafe { (*parent).entry.rbe_right }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_parent = parent });
                }
                (unsafe { (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent });
                if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                    if parent == (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left }) {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left = tmp });
                    } else {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_right = tmp });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).entry.rbe_left = parent });
                (unsafe { (*parent).entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
                elm = unsafe { (*head).rbh_root };
                break;
            }
        } else {
            tmp = unsafe { (*parent).entry.rbe_left };
            if (unsafe { (*tmp).entry.rbe_color }) == 1 as i32 {
                (unsafe { (*tmp).entry.rbe_color = 0 as i32 });
                (unsafe { (*parent).entry.rbe_color = 1 as i32 });
                tmp = unsafe { (*parent).entry.rbe_left };
                (unsafe { (*parent).entry.rbe_left = (*tmp).entry.rbe_right });
                if !(unsafe { (*parent).entry.rbe_left }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_parent = parent });
                }
                (unsafe { (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent });
                if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                    if parent == (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left }) {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left = tmp });
                    } else {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_right = tmp });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).entry.rbe_right = parent });
                (unsafe { (*parent).entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
                tmp = unsafe { (*parent).entry.rbe_left };
            }
            if ((unsafe { (*tmp).entry.rbe_left }).is_null()
                || (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_color }) == 0 as i32)
                && ((unsafe { (*tmp).entry.rbe_right }).is_null()
                    || (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_color }) == 0 as i32)
            {
                (unsafe { (*tmp).entry.rbe_color = 1 as i32 });
                elm = parent;
                parent = unsafe { (*elm).entry.rbe_parent };
            } else {
                if (unsafe { (*tmp).entry.rbe_left }).is_null()
                    || (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_color }) == 0 as i32
                {
                    let mut oright: *mut format_entry = std::ptr::null_mut::<format_entry>();
                    oright = unsafe { (*tmp).entry.rbe_right };
                    if !oright.is_null() {
                        (unsafe { (*oright).entry.rbe_color = 0 as i32 });
                    }
                    (unsafe { (*tmp).entry.rbe_color = 1 as i32 });
                    oright = unsafe { (*tmp).entry.rbe_right };
                    (unsafe { (*tmp).entry.rbe_right = (*oright).entry.rbe_left });
                    if !(unsafe { (*tmp).entry.rbe_right }).is_null() {
                        (unsafe { (*(*oright).entry.rbe_left).entry.rbe_parent = tmp });
                    }
                    (unsafe { (*oright).entry.rbe_parent = (*tmp).entry.rbe_parent });
                    if !(unsafe { (*oright).entry.rbe_parent }).is_null() {
                        if tmp == (unsafe { (*(*tmp).entry.rbe_parent).entry.rbe_left }) {
                            (unsafe { (*(*tmp).entry.rbe_parent).entry.rbe_left = oright });
                        } else {
                            (unsafe { (*(*tmp).entry.rbe_parent).entry.rbe_right = oright });
                        }
                    } else {
                        (unsafe { (*head).rbh_root = oright });
                    }
                    (unsafe { (*oright).entry.rbe_left = tmp });
                    (unsafe { (*tmp).entry.rbe_parent = oright });
                    let _ = !(unsafe { (*oright).entry.rbe_parent }).is_null();
                    tmp = unsafe { (*parent).entry.rbe_left };
                }
                (unsafe { (*tmp).entry.rbe_color = (*parent).entry.rbe_color });
                (unsafe { (*parent).entry.rbe_color = 0 as i32 });
                if !(unsafe { (*tmp).entry.rbe_left }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_left).entry.rbe_color = 0 as i32 });
                }
                tmp = unsafe { (*parent).entry.rbe_left };
                (unsafe { (*parent).entry.rbe_left = (*tmp).entry.rbe_right });
                if !(unsafe { (*parent).entry.rbe_left }).is_null() {
                    (unsafe { (*(*tmp).entry.rbe_right).entry.rbe_parent = parent });
                }
                (unsafe { (*tmp).entry.rbe_parent = (*parent).entry.rbe_parent });
                if !(unsafe { (*tmp).entry.rbe_parent }).is_null() {
                    if parent == (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left }) {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_left = tmp });
                    } else {
                        (unsafe { (*(*parent).entry.rbe_parent).entry.rbe_right = tmp });
                    }
                } else {
                    (unsafe { (*head).rbh_root = tmp });
                }
                (unsafe { (*tmp).entry.rbe_right = parent });
                (unsafe { (*parent).entry.rbe_parent = tmp });
                let _ = !(unsafe { (*tmp).entry.rbe_parent }).is_null();
                elm = unsafe { (*head).rbh_root };
                break;
            }
        }
    }
    if !elm.is_null() {
        (unsafe { (*elm).entry.rbe_color = 0 as i32 });
    }
}
extern "C" fn format_entry_tree_RB_NEXT(mut elm: *mut format_entry) -> *mut format_entry {
    if !(unsafe { (*elm).entry.rbe_right }).is_null() {
        elm = unsafe { (*elm).entry.rbe_right };
        while !(unsafe { (*elm).entry.rbe_left }).is_null() {
            elm = unsafe { (*elm).entry.rbe_left };
        }
    } else if !(unsafe { (*elm).entry.rbe_parent }).is_null()
        && elm == (unsafe { (*(*elm).entry.rbe_parent).entry.rbe_left })
    {
        elm = unsafe { (*elm).entry.rbe_parent };
    } else {
        while !(unsafe { (*elm).entry.rbe_parent }).is_null()
            && elm == (unsafe { (*(*elm).entry.rbe_parent).entry.rbe_right })
        {
            elm = unsafe { (*elm).entry.rbe_parent };
        }
        elm = unsafe { (*elm).entry.rbe_parent };
    }
    return elm;
}
extern "C" fn format_entry_cmp(mut fe1: *mut format_entry, mut fe2: *mut format_entry) -> i32 {
    return unsafe { strcmp((*fe1).key, (*fe2).key) };
}
static mut format_upper: [*const i8; 26] = [
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    b"pane_id\0" as *const u8 as *const i8,
    0 as *const i8,
    b"window_flags\0" as *const u8 as *const i8,
    0 as *const i8,
    b"host\0" as *const u8 as *const i8,
    b"window_index\0" as *const u8 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    b"pane_index\0" as *const u8 as *const i8,
    0 as *const i8,
    0 as *const i8,
    b"session_name\0" as *const u8 as *const i8,
    b"pane_title\0" as *const u8 as *const i8,
    0 as *const i8,
    0 as *const i8,
    b"window_name\0" as *const u8 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
];
static mut format_lower: [*const i8; 26] = [
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    b"host_short\0" as *const u8 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
    0 as *const i8,
];
#[inline]
extern "C" fn format_logging(mut ft: *mut format_tree) -> i32 {
    return ((unsafe { log_get_level() }) != 0 as i32 || (unsafe { (*ft).flags }) & 0x8 as i32 != 0)
        as i32;
}
unsafe extern "C" fn format_log1(
    mut es: *mut format_expand_state,
    mut from: *const i8,
    mut fmt: *const i8,
    mut args: ...
) {
    let mut ft: *mut format_tree = (*es).ft;
    let mut ap: ::core::ffi::VaListImpl;
    let mut s: *mut i8 = std::ptr::null_mut::<i8>();
    static mut spaces: [i8; 11] =
        unsafe { *::core::mem::transmute::<&[u8; 11], &[i8; 11]>(b"          \0") };
    if format_logging(ft) == 0 {
        return;
    }
    ap = args.clone();
    xvasprintf(&mut s, fmt, ap.as_va_list());
    log_debug(b"%s: %s\0" as *const u8 as *const i8, from, s);
    if !((*ft).item).is_null() && (*ft).flags & 0x8 as i32 != 0 {
        cmdq_print(
            (*ft).item,
            b"#%.*s%s\0" as *const u8 as *const i8,
            (*es).loop_0,
            spaces.as_ptr(),
            s,
        );
    }
    free(s as *mut libc::c_void);
}
extern "C" fn format_copy_state(
    mut to: *mut format_expand_state,
    mut from: *mut format_expand_state,
    mut flags: i32,
) {
    (unsafe { (*to).ft = (*from).ft });
    (unsafe { (*to).loop_0 = (*from).loop_0 });
    (unsafe { (*to).time = (*from).time });
    (unsafe {
        memcpy(
            &mut (*to).tm as *mut tm as *mut libc::c_void,
            &mut (*from).tm as *mut tm as *const libc::c_void,
            ::core::mem::size_of::<tm>() as u64,
        )
    });
    (unsafe { (*to).flags = (*from).flags | flags });
}
extern "C" fn format_job_update(mut job: *mut job) {
    let mut fj: *mut format_job = (unsafe { job_get_data(job) }) as *mut format_job;
    let mut evb: *mut evbuffer = unsafe { (*job_get_event(job)).input };
    let mut line: *mut i8 = std::ptr::null_mut::<i8>();
    let mut next: *mut i8 = std::ptr::null_mut::<i8>();
    let mut t: time_t = 0;
    loop {
        next = unsafe { evbuffer_readline(evb) };
        if next.is_null() {
            break;
        }
        (unsafe { free(line as *mut libc::c_void) });
        line = next;
    }
    if line.is_null() {
        return;
    }
    (unsafe { (*fj).updated = 1 as i32 });
    (unsafe { free((*fj).out as *mut libc::c_void) });
    (unsafe { (*fj).out = line });
    (unsafe {
        log_debug(
            b"%s: %p %s: %s\0" as *const u8 as *const i8,
            (*::core::mem::transmute::<&[u8; 18], &[i8; 18]>(b"format_job_update\0")).as_ptr(),
            fj,
            (*fj).cmd,
            (*fj).out,
        )
    });
    t = unsafe { time(std::ptr::null_mut::<time_t>()) };
    if (unsafe { (*fj).status }) != 0 && (unsafe { (*fj).last }) != t {
        if !(unsafe { (*fj).client }).is_null() {
            (unsafe { server_status_client((*fj).client) });
        }
        (unsafe { (*fj).last = t });
    }
}
extern "C" fn format_job_complete(mut job: *mut job) {
    let mut fj: *mut format_job = (unsafe { job_get_data(job) }) as *mut format_job;
    let mut evb: *mut evbuffer = unsafe { (*job_get_event(job)).input };
    let mut line: *mut i8 = std::ptr::null_mut::<i8>();
    let mut buf: *mut i8 = std::ptr::null_mut::<i8>();
    let mut len: size_t = 0;
    (unsafe { (*fj).job = std::ptr::null_mut::<job>() });
    buf = std::ptr::null_mut::<i8>();
    line = unsafe { evbuffer_readline(evb) };
    if line.is_null() {
        len = unsafe { evbuffer_get_length(evb) };
        buf = (unsafe { xmalloc(len.wrapping_add(1 as i32 as u64)) }) as *mut i8;
        if len != 0 as i32 as u64 {
            (unsafe {
                memcpy(
                    buf as *mut libc::c_void,
                    evbuffer_pullup(evb, -(1 as i32) as ssize_t) as *const libc::c_void,
                    len,
                )
            });
        }
        (unsafe { *buf.offset(len as isize) = '\0' as i32 as i8 });
    } else {
        buf = line;
    }
    (unsafe {
        log_debug(
            b"%s: %p %s: %s\0" as *const u8 as *const i8,
            (*::core::mem::transmute::<&[u8; 20], &[i8; 20]>(b"format_job_complete\0")).as_ptr(),
            fj,
            (*fj).cmd,
            buf,
        )
    });
    if (unsafe { *buf }) as i32 != '\0' as i32 || (unsafe { (*fj).updated }) == 0 {
        (unsafe { free((*fj).out as *mut libc::c_void) });
        (unsafe { (*fj).out = buf });
    } else {
        (unsafe { free(buf as *mut libc::c_void) });
    }
    if (unsafe { (*fj).status }) != 0 {
        if !(unsafe { (*fj).client }).is_null() {
            (unsafe { server_status_client((*fj).client) });
        }
        (unsafe { (*fj).status = 0 as i32 });
    }
}
extern "C" fn format_job_get(mut es: *mut format_expand_state, mut cmd: *const i8) -> *mut i8 {
    let mut ft: *mut format_tree = unsafe { (*es).ft };
    let mut jobs: *mut format_job_tree = std::ptr::null_mut::<format_job_tree>();
    let mut fj0: format_job = format_job {
        client: std::ptr::null_mut::<client>(),
        tag: 0,
        cmd: std::ptr::null::<i8>(),
        expanded: std::ptr::null::<i8>(),
        last: 0,
        out: std::ptr::null_mut::<i8>(),
        updated: 0,
        job: std::ptr::null_mut::<job>(),
        status: 0,
        entry: C2RustUnnamed_35 {
            rbe_left: std::ptr::null_mut::<format_job>(),
            rbe_right: std::ptr::null_mut::<format_job>(),
            rbe_parent: std::ptr::null_mut::<format_job>(),
            rbe_color: 0,
        },
    };
    let mut fj: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut t: time_t = 0;
    let mut expanded: *mut i8 = std::ptr::null_mut::<i8>();
    let mut force: i32 = 0;
    let mut next: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<i8>(),
        },
        flags: 0,
    };
    if (unsafe { (*ft).client }).is_null() {
        jobs = unsafe { &mut format_jobs };
    } else if !(unsafe { (*(*ft).client).jobs }).is_null() {
        jobs = unsafe { (*(*ft).client).jobs };
    } else {
        (unsafe {
            (*(*ft).client).jobs =
                xmalloc(::core::mem::size_of::<format_job_tree>() as u64) as *mut format_job_tree
        });
        jobs = unsafe { (*(*ft).client).jobs };
        (unsafe { (*jobs).rbh_root = std::ptr::null_mut::<format_job>() });
    }
    fj0.tag = unsafe { (*ft).tag };
    fj0.cmd = cmd;
    fj = format_job_tree_RB_FIND(jobs, &mut fj0);
    if fj.is_null() {
        fj = (unsafe {
            xcalloc(
                1 as i32 as size_t,
                ::core::mem::size_of::<format_job>() as u64,
            )
        }) as *mut format_job;
        (unsafe { (*fj).client = (*ft).client });
        (unsafe { (*fj).tag = (*ft).tag });
        (unsafe { (*fj).cmd = xstrdup(cmd) });
        format_job_tree_RB_INSERT(jobs, fj);
    }
    format_copy_state(&mut next, es, 0x2 as i32);
    next.flags &= !(0x1 as i32);
    expanded = format_expand1(&mut next, cmd);
    if (unsafe { (*fj).expanded }).is_null()
        || (unsafe { strcmp(expanded, (*fj).expanded) }) != 0 as i32
    {
        (unsafe { free((*fj).expanded as *mut libc::c_void) });
        (unsafe { (*fj).expanded = xstrdup(expanded) });
        force = 1 as i32;
    } else {
        force = (unsafe { (*ft).flags }) & 0x2 as i32;
    }
    t = unsafe { time(std::ptr::null_mut::<time_t>()) };
    if force != 0 && !(unsafe { (*fj).job }).is_null() {
        (unsafe { job_free((*fj).job) });
    }
    if force != 0 || (unsafe { (*fj).job }).is_null() && (unsafe { (*fj).last }) != t {
        (unsafe {
            (*fj).job = job_run(
                expanded,
                0 as i32,
                std::ptr::null_mut::<*mut i8>(),
                std::ptr::null_mut::<environ>(),
                std::ptr::null_mut::<session>(),
                server_client_get_cwd((*ft).client, std::ptr::null_mut::<session>()),
                Some(format_job_update as unsafe extern "C" fn(*mut job) -> ()),
                Some(format_job_complete as unsafe extern "C" fn(*mut job) -> ()),
                None,
                fj as *mut libc::c_void,
                0x1 as i32,
                -(1 as i32),
                -(1 as i32),
            )
        });
        if (unsafe { (*fj).job }).is_null() {
            (unsafe { free((*fj).out as *mut libc::c_void) });
            (unsafe {
                xasprintf(
                    &mut (*fj).out as *mut *mut i8,
                    b"<'%s' didn't start>\0" as *const u8 as *const i8,
                    (*fj).cmd,
                )
            });
        }
        (unsafe { (*fj).last = t });
        (unsafe { (*fj).updated = 0 as i32 });
    } else if !(unsafe { (*fj).job }).is_null()
        && t - (unsafe { (*fj).last }) > 1 as i32 as i64
        && (unsafe { (*fj).out }).is_null()
    {
        (unsafe {
            xasprintf(
                &mut (*fj).out as *mut *mut i8,
                b"<'%s' not ready>\0" as *const u8 as *const i8,
                (*fj).cmd,
            )
        });
    }
    (unsafe { free(expanded as *mut libc::c_void) });
    if (unsafe { (*ft).flags }) & 0x1 as i32 != 0 {
        (unsafe { (*fj).status = 1 as i32 });
    }
    if (unsafe { (*fj).out }).is_null() {
        return unsafe { xstrdup(b"\0" as *const u8 as *const i8) };
    }
    return format_expand1(&mut next, unsafe { (*fj).out });
}
extern "C" fn format_job_tidy(mut jobs: *mut format_job_tree, mut force: i32) {
    let mut fj: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut fj1: *mut format_job = std::ptr::null_mut::<format_job>();
    let mut now: time_t = 0;
    now = unsafe { time(std::ptr::null_mut::<time_t>()) };
    fj = format_job_tree_RB_MINMAX(jobs, -(1 as i32));
    while !fj.is_null() && {
        fj1 = format_job_tree_RB_NEXT(fj);
        1 as i32 != 0
    } {
        if !(force == 0
            && ((unsafe { (*fj).last }) > now
                || now - (unsafe { (*fj).last }) < 3600 as i32 as i64))
        {
            format_job_tree_RB_REMOVE(jobs, fj);
            (unsafe {
                log_debug(
                    b"%s: %s\0" as *const u8 as *const i8,
                    (*::core::mem::transmute::<&[u8; 16], &[i8; 16]>(b"format_job_tidy\0"))
                        .as_ptr(),
                    (*fj).cmd,
                )
            });
            if !(unsafe { (*fj).job }).is_null() {
                (unsafe { job_free((*fj).job) });
            }
            (unsafe { free((*fj).expanded as *mut libc::c_void) });
            (unsafe { free((*fj).cmd as *mut libc::c_void) });
            (unsafe { free((*fj).out as *mut libc::c_void) });
            (unsafe { free(fj as *mut libc::c_void) });
        }
        fj = fj1;
    }
}
#[no_mangle]
pub extern "C" fn format_tidy_jobs() {
    let mut c: *mut client = std::ptr::null_mut::<client>();
    format_job_tidy(unsafe { &mut format_jobs }, 0 as i32);
    c = unsafe { clients.tqh_first };
    while !c.is_null() {
        if !(unsafe { (*c).jobs }).is_null() {
            format_job_tidy(unsafe { (*c).jobs }, 0 as i32);
        }
        c = unsafe { (*c).entry.tqe_next };
    }
}
#[no_mangle]
pub extern "C" fn format_lost_client(mut c: *mut client) {
    if !(unsafe { (*c).jobs }).is_null() {
        format_job_tidy(unsafe { (*c).jobs }, 1 as i32);
    }
    (unsafe { free((*c).jobs as *mut libc::c_void) });
}
unsafe extern "C" fn format_printf(mut fmt: *const i8, mut args: ...) -> *mut i8 {
    let mut ap: ::core::ffi::VaListImpl;
    let mut s: *mut i8 = std::ptr::null_mut::<i8>();
    ap = args.clone();
    xvasprintf(&mut s, fmt, ap.as_va_list());
    return s;
}
extern "C" fn format_cb_host(mut _ft: *mut format_tree) -> *mut libc::c_void {
    let mut host: [i8; 65] = [0; 65];
    if (unsafe { gethostname(host.as_mut_ptr(), ::core::mem::size_of::<[i8; 65]>() as u64) })
        != 0 as i32
    {
        return (unsafe { xstrdup(b"\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return (unsafe { xstrdup(host.as_mut_ptr()) }) as *mut libc::c_void;
}
extern "C" fn format_cb_host_short(mut _ft: *mut format_tree) -> *mut libc::c_void {
    let mut host: [i8; 65] = [0; 65];
    let mut cp: *mut i8 = std::ptr::null_mut::<i8>();
    if (unsafe { gethostname(host.as_mut_ptr(), ::core::mem::size_of::<[i8; 65]>() as u64) })
        != 0 as i32
    {
        return (unsafe { xstrdup(b"\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    cp = unsafe { strchr(host.as_mut_ptr(), '.' as i32) };
    if !cp.is_null() {
        (unsafe { *cp = '\0' as i32 as i8 });
    }
    return (unsafe { xstrdup(host.as_mut_ptr()) }) as *mut libc::c_void;
}
extern "C" fn format_cb_pid(mut _ft: *mut format_tree) -> *mut libc::c_void {
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    (unsafe {
        xasprintf(
            &mut value as *mut *mut i8,
            b"%ld\0" as *const u8 as *const i8,
            getpid() as i64,
        )
    });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_session_attached_list(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut session = unsafe { (*ft).s };
    let mut loop_0: *mut client = std::ptr::null_mut::<client>();
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut size: i32 = 0;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if s.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    buffer = unsafe { evbuffer_new() };
    if buffer.is_null() {
        (unsafe { fatalx(b"out of memory\0" as *const u8 as *const i8) });
    }
    loop_0 = unsafe { clients.tqh_first };
    while !loop_0.is_null() {
        if (unsafe { (*loop_0).session }) == s {
            if (unsafe { evbuffer_get_length(buffer) }) > 0 as i32 as u64 {
                (unsafe {
                    evbuffer_add(
                        buffer,
                        b",\0" as *const u8 as *const i8 as *const libc::c_void,
                        1 as i32 as size_t,
                    )
                });
            }
            (unsafe {
                evbuffer_add_printf(buffer, b"%s\0" as *const u8 as *const i8, (*loop_0).name)
            });
        }
        loop_0 = unsafe { (*loop_0).entry.tqe_next };
    }
    size = (unsafe { evbuffer_get_length(buffer) }) as i32;
    if size != 0 as i32 {
        (unsafe {
            xasprintf(
                &mut value as *mut *mut i8,
                b"%.*s\0" as *const u8 as *const i8,
                size,
                evbuffer_pullup(buffer, -(1 as i32) as ssize_t),
            )
        });
    }
    (unsafe { evbuffer_free(buffer) });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_session_alerts(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut session = unsafe { (*ft).s };
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut alerts: [i8; 1024] = [0; 1024];
    let mut tmp: [i8; 16] = [0; 16];
    if s.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    (unsafe { *alerts.as_mut_ptr() = '\0' as i32 as i8 });
    wl = unsafe { winlinks_RB_MINMAX(&mut (*s).windows, -(1 as i32)) };
    while !wl.is_null() {
        if (unsafe { (*wl).flags }) & (0x1 as i32 | 0x2 as i32 | 0x4 as i32) != 0 as i32 {
            (unsafe {
                xsnprintf(
                    tmp.as_mut_ptr(),
                    ::core::mem::size_of::<[i8; 16]>() as u64,
                    b"%u\0" as *const u8 as *const i8,
                    (*wl).idx,
                )
            });
            if (unsafe { *alerts.as_mut_ptr() }) as i32 != '\0' as i32 {
                (unsafe {
                    strlcat(
                        alerts.as_mut_ptr(),
                        b",\0" as *const u8 as *const i8,
                        ::core::mem::size_of::<[i8; 1024]>() as u64,
                    )
                });
            }
            (unsafe {
                strlcat(
                    alerts.as_mut_ptr(),
                    tmp.as_mut_ptr(),
                    ::core::mem::size_of::<[i8; 1024]>() as u64,
                )
            });
            if (unsafe { (*wl).flags }) & 0x2 as i32 != 0 {
                (unsafe {
                    strlcat(
                        alerts.as_mut_ptr(),
                        b"#\0" as *const u8 as *const i8,
                        ::core::mem::size_of::<[i8; 1024]>() as u64,
                    )
                });
            }
            if (unsafe { (*wl).flags }) & 0x1 as i32 != 0 {
                (unsafe {
                    strlcat(
                        alerts.as_mut_ptr(),
                        b"!\0" as *const u8 as *const i8,
                        ::core::mem::size_of::<[i8; 1024]>() as u64,
                    )
                });
            }
            if (unsafe { (*wl).flags }) & 0x4 as i32 != 0 {
                (unsafe {
                    strlcat(
                        alerts.as_mut_ptr(),
                        b"~\0" as *const u8 as *const i8,
                        ::core::mem::size_of::<[i8; 1024]>() as u64,
                    )
                });
            }
        }
        wl = unsafe { winlinks_RB_NEXT(wl) };
    }
    return (unsafe { xstrdup(alerts.as_mut_ptr()) }) as *mut libc::c_void;
}
extern "C" fn format_cb_session_stack(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut session = unsafe { (*ft).s };
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut result: [i8; 1024] = [0; 1024];
    let mut tmp: [i8; 16] = [0; 16];
    if s.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    (unsafe {
        xsnprintf(
            result.as_mut_ptr(),
            ::core::mem::size_of::<[i8; 1024]>() as u64,
            b"%u\0" as *const u8 as *const i8,
            (*(*s).curw).idx,
        )
    });
    wl = unsafe { (*s).lastw.tqh_first };
    while !wl.is_null() {
        (unsafe {
            xsnprintf(
                tmp.as_mut_ptr(),
                ::core::mem::size_of::<[i8; 16]>() as u64,
                b"%u\0" as *const u8 as *const i8,
                (*wl).idx,
            )
        });
        if (unsafe { *result.as_mut_ptr() }) as i32 != '\0' as i32 {
            (unsafe {
                strlcat(
                    result.as_mut_ptr(),
                    b",\0" as *const u8 as *const i8,
                    ::core::mem::size_of::<[i8; 1024]>() as u64,
                )
            });
        }
        (unsafe {
            strlcat(
                result.as_mut_ptr(),
                tmp.as_mut_ptr(),
                ::core::mem::size_of::<[i8; 1024]>() as u64,
            )
        });
        wl = unsafe { (*wl).sentry.tqe_next };
    }
    return (unsafe { xstrdup(result.as_mut_ptr()) }) as *mut libc::c_void;
}
extern "C" fn format_cb_window_stack_index(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut session = std::ptr::null_mut::<session>();
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut idx: u_int = 0;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if (unsafe { (*ft).wl }).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    s = unsafe { (*(*ft).wl).session };
    idx = 0 as i32 as u_int;
    wl = unsafe { (*s).lastw.tqh_first };
    while !wl.is_null() {
        idx = idx.wrapping_add(1);
        if wl == (unsafe { (*ft).wl }) {
            break;
        }
        wl = unsafe { (*wl).sentry.tqe_next };
    }
    if wl.is_null() {
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    (unsafe {
        xasprintf(
            &mut value as *mut *mut i8,
            b"%u\0" as *const u8 as *const i8,
            idx,
        )
    });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_window_linked_sessions_list(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut size: i32 = 0;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if (unsafe { (*ft).wl }).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = unsafe { (*(*ft).wl).window };
    buffer = unsafe { evbuffer_new() };
    if buffer.is_null() {
        (unsafe { fatalx(b"out of memory\0" as *const u8 as *const i8) });
    }
    wl = unsafe { (*w).winlinks.tqh_first };
    while !wl.is_null() {
        if (unsafe { evbuffer_get_length(buffer) }) > 0 as i32 as u64 {
            (unsafe {
                evbuffer_add(
                    buffer,
                    b",\0" as *const u8 as *const i8 as *const libc::c_void,
                    1 as i32 as size_t,
                )
            });
        }
        (unsafe {
            evbuffer_add_printf(
                buffer,
                b"%s\0" as *const u8 as *const i8,
                (*(*wl).session).name,
            )
        });
        wl = unsafe { (*wl).wentry.tqe_next };
    }
    size = (unsafe { evbuffer_get_length(buffer) }) as i32;
    if size != 0 as i32 {
        (unsafe {
            xasprintf(
                &mut value as *mut *mut i8,
                b"%.*s\0" as *const u8 as *const i8,
                size,
                evbuffer_pullup(buffer, -(1 as i32) as ssize_t),
            )
        });
    }
    (unsafe { evbuffer_free(buffer) });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_window_active_sessions(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut n: u_int = 0 as i32 as u_int;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if (unsafe { (*ft).wl }).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = unsafe { (*(*ft).wl).window };
    wl = unsafe { (*w).winlinks.tqh_first };
    while !wl.is_null() {
        if (unsafe { (*(*wl).session).curw }) == wl {
            n = n.wrapping_add(1);
        }
        wl = unsafe { (*wl).wentry.tqe_next };
    }
    (unsafe {
        xasprintf(
            &mut value as *mut *mut i8,
            b"%u\0" as *const u8 as *const i8,
            n,
        )
    });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_window_active_sessions_list(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut size: i32 = 0;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if (unsafe { (*ft).wl }).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = unsafe { (*(*ft).wl).window };
    buffer = unsafe { evbuffer_new() };
    if buffer.is_null() {
        (unsafe { fatalx(b"out of memory\0" as *const u8 as *const i8) });
    }
    wl = unsafe { (*w).winlinks.tqh_first };
    while !wl.is_null() {
        if (unsafe { (*(*wl).session).curw }) == wl {
            if (unsafe { evbuffer_get_length(buffer) }) > 0 as i32 as u64 {
                (unsafe {
                    evbuffer_add(
                        buffer,
                        b",\0" as *const u8 as *const i8 as *const libc::c_void,
                        1 as i32 as size_t,
                    )
                });
            }
            (unsafe {
                evbuffer_add_printf(
                    buffer,
                    b"%s\0" as *const u8 as *const i8,
                    (*(*wl).session).name,
                )
            });
        }
        wl = unsafe { (*wl).wentry.tqe_next };
    }
    size = (unsafe { evbuffer_get_length(buffer) }) as i32;
    if size != 0 as i32 {
        (unsafe {
            xasprintf(
                &mut value as *mut *mut i8,
                b"%.*s\0" as *const u8 as *const i8,
                size,
                evbuffer_pullup(buffer, -(1 as i32) as ssize_t),
            )
        });
    }
    (unsafe { evbuffer_free(buffer) });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_window_active_clients(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut loop_0: *mut client = std::ptr::null_mut::<client>();
    let mut client_session: *mut session = std::ptr::null_mut::<session>();
    let mut n: u_int = 0 as i32 as u_int;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if (unsafe { (*ft).wl }).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = unsafe { (*(*ft).wl).window };
    loop_0 = unsafe { clients.tqh_first };
    while !loop_0.is_null() {
        client_session = unsafe { (*loop_0).session };
        if !client_session.is_null() {
            if w == (unsafe { (*(*client_session).curw).window }) {
                n = n.wrapping_add(1);
            }
        }
        loop_0 = unsafe { (*loop_0).entry.tqe_next };
    }
    (unsafe {
        xasprintf(
            &mut value as *mut *mut i8,
            b"%u\0" as *const u8 as *const i8,
            n,
        )
    });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_window_active_clients_list(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut loop_0: *mut client = std::ptr::null_mut::<client>();
    let mut client_session: *mut session = std::ptr::null_mut::<session>();
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut size: i32 = 0;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if (unsafe { (*ft).wl }).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = unsafe { (*(*ft).wl).window };
    buffer = unsafe { evbuffer_new() };
    if buffer.is_null() {
        (unsafe { fatalx(b"out of memory\0" as *const u8 as *const i8) });
    }
    loop_0 = unsafe { clients.tqh_first };
    while !loop_0.is_null() {
        client_session = unsafe { (*loop_0).session };
        if !client_session.is_null() {
            if w == (unsafe { (*(*client_session).curw).window }) {
                if (unsafe { evbuffer_get_length(buffer) }) > 0 as i32 as u64 {
                    (unsafe {
                        evbuffer_add(
                            buffer,
                            b",\0" as *const u8 as *const i8 as *const libc::c_void,
                            1 as i32 as size_t,
                        )
                    });
                }
                (unsafe {
                    evbuffer_add_printf(buffer, b"%s\0" as *const u8 as *const i8, (*loop_0).name)
                });
            }
        }
        loop_0 = unsafe { (*loop_0).entry.tqe_next };
    }
    size = (unsafe { evbuffer_get_length(buffer) }) as i32;
    if size != 0 as i32 {
        (unsafe {
            xasprintf(
                &mut value as *mut *mut i8,
                b"%.*s\0" as *const u8 as *const i8,
                size,
                evbuffer_pullup(buffer, -(1 as i32) as ssize_t),
            )
        });
    }
    (unsafe { evbuffer_free(buffer) });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_window_layout(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut w: *mut window = unsafe { (*ft).w };
    if w.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if !(unsafe { (*w).saved_layout_root }).is_null() {
        return (unsafe { layout_dump((*w).saved_layout_root) }) as *mut libc::c_void;
    }
    return (unsafe { layout_dump((*w).layout_root) }) as *mut libc::c_void;
}
extern "C" fn format_cb_window_visible_layout(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut w: *mut window = unsafe { (*ft).w };
    if w.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    return (unsafe { layout_dump((*w).layout_root) }) as *mut libc::c_void;
}
extern "C" fn format_cb_start_command(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    return (unsafe { cmd_stringify_argv((*wp).argc, (*wp).argv) }) as *mut libc::c_void;
}
extern "C" fn format_cb_start_path(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if (unsafe { (*wp).cwd }).is_null() {
        return (unsafe { xstrdup(b"\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return (unsafe { xstrdup((*wp).cwd) }) as *mut libc::c_void;
}
extern "C" fn format_cb_current_command(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut cmd: *mut i8 = std::ptr::null_mut::<i8>();
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if wp.is_null() || (unsafe { (*wp).shell }).is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    cmd = unsafe { osdep_get_name((*wp).fd, ((*wp).tty).as_mut_ptr()) };
    if cmd.is_null() || (unsafe { *cmd }) as i32 == '\0' as i32 {
        (unsafe { free(cmd as *mut libc::c_void) });
        cmd = unsafe { cmd_stringify_argv((*wp).argc, (*wp).argv) };
        if cmd.is_null() || (unsafe { *cmd }) as i32 == '\0' as i32 {
            (unsafe { free(cmd as *mut libc::c_void) });
            cmd = unsafe { xstrdup((*wp).shell) };
        }
    }
    value = unsafe { parse_window_name(cmd) };
    (unsafe { free(cmd as *mut libc::c_void) });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_current_path(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut cwd: *mut i8 = std::ptr::null_mut::<i8>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    cwd = unsafe { osdep_get_cwd((*wp).fd) };
    if cwd.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    return (unsafe { xstrdup(cwd) }) as *mut libc::c_void;
}
extern "C" fn format_cb_history_bytes(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut gd: *mut grid = std::ptr::null_mut::<grid>();
    let mut gl: *mut grid_line = std::ptr::null_mut::<grid_line>();
    let mut size: size_t = 0 as i32 as size_t;
    let mut i: u_int = 0;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    gd = unsafe { (*wp).base.grid };
    i = 0 as i32 as u_int;
    while i < (unsafe { (*gd).hsize }).wrapping_add(unsafe { (*gd).sy }) {
        gl = unsafe { grid_get_line(gd, i) };
        size = (size as u64).wrapping_add(
            ((unsafe { (*gl).cellsize }) as u64)
                .wrapping_mul(::core::mem::size_of::<grid_cell_entry>() as u64),
        ) as size_t as size_t;
        size = (size as u64).wrapping_add(
            ((unsafe { (*gl).extdsize }) as u64)
                .wrapping_mul(::core::mem::size_of::<grid_extd_entry>() as u64),
        ) as size_t as size_t;
        i = i.wrapping_add(1);
    }
    size = (size as u64).wrapping_add(
        ((unsafe { (*gd).hsize }).wrapping_add(unsafe { (*gd).sy }) as u64)
            .wrapping_mul(::core::mem::size_of::<grid_line>() as u64),
    ) as size_t as size_t;
    (unsafe {
        xasprintf(
            &mut value as *mut *mut i8,
            b"%zu\0" as *const u8 as *const i8,
            size,
        )
    });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_history_all_bytes(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut gd: *mut grid = std::ptr::null_mut::<grid>();
    let mut gl: *mut grid_line = std::ptr::null_mut::<grid_line>();
    let mut i: u_int = 0;
    let mut lines: u_int = 0;
    let mut cells: u_int = 0 as i32 as u_int;
    let mut extended_cells: u_int = 0 as i32 as u_int;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    gd = unsafe { (*wp).base.grid };
    lines = (unsafe { (*gd).hsize }).wrapping_add(unsafe { (*gd).sy });
    i = 0 as i32 as u_int;
    while i < lines {
        gl = unsafe { grid_get_line(gd, i) };
        cells = (cells as u32).wrapping_add(unsafe { (*gl).cellsize }) as u_int as u_int;
        extended_cells =
            (extended_cells as u32).wrapping_add(unsafe { (*gl).extdsize }) as u_int as u_int;
        i = i.wrapping_add(1);
    }
    (unsafe {
        xasprintf(
            &mut value as *mut *mut i8,
            b"%u,%zu,%u,%zu,%u,%zu\0" as *const u8 as *const i8,
            lines,
            (lines as u64).wrapping_mul(::core::mem::size_of::<grid_line>() as u64),
            cells,
            (cells as u64).wrapping_mul(::core::mem::size_of::<grid_cell_entry>() as u64),
            extended_cells,
            (extended_cells as u64).wrapping_mul(::core::mem::size_of::<grid_extd_entry>() as u64),
        )
    });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_pane_tabs(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut i: u_int = 0;
    let mut size: i32 = 0;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    buffer = unsafe { evbuffer_new() };
    if buffer.is_null() {
        (unsafe { fatalx(b"out of memory\0" as *const u8 as *const i8) });
    }
    i = 0 as i32 as u_int;
    while i < (unsafe { (*(*wp).base.grid).sx }) {
        if (unsafe { *((*wp).base.tabs).offset((i >> 3 as i32) as isize) }) as i32
            & (1 as i32) << (i & 0x7 as i32 as u32)
            != 0
        {
            if (unsafe { evbuffer_get_length(buffer) }) > 0 as i32 as u64 {
                (unsafe {
                    evbuffer_add(
                        buffer,
                        b",\0" as *const u8 as *const i8 as *const libc::c_void,
                        1 as i32 as size_t,
                    )
                });
            }
            (unsafe { evbuffer_add_printf(buffer, b"%u\0" as *const u8 as *const i8, i) });
        }
        i = i.wrapping_add(1);
    }
    size = (unsafe { evbuffer_get_length(buffer) }) as i32;
    if size != 0 as i32 {
        (unsafe {
            xasprintf(
                &mut value as *mut *mut i8,
                b"%.*s\0" as *const u8 as *const i8,
                size,
                evbuffer_pullup(buffer, -(1 as i32) as ssize_t),
            )
        });
    }
    (unsafe { evbuffer_free(buffer) });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_pane_fg(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    (unsafe { tty_default_colours(&mut gc, wp) });
    return (unsafe { xstrdup(colour_tostring(gc.fg)) }) as *mut libc::c_void;
}
extern "C" fn format_cb_pane_bg(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    (unsafe { tty_default_colours(&mut gc, wp) });
    return (unsafe { xstrdup(colour_tostring(gc.bg)) }) as *mut libc::c_void;
}
extern "C" fn format_cb_session_group_list(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut session = unsafe { (*ft).s };
    let mut sg: *mut session_group = std::ptr::null_mut::<session_group>();
    let mut loop_0: *mut session = std::ptr::null_mut::<session>();
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut size: i32 = 0;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if s.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    sg = unsafe { session_group_contains(s) };
    if sg.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    buffer = unsafe { evbuffer_new() };
    if buffer.is_null() {
        (unsafe { fatalx(b"out of memory\0" as *const u8 as *const i8) });
    }
    loop_0 = unsafe { (*sg).sessions.tqh_first };
    while !loop_0.is_null() {
        if (unsafe { evbuffer_get_length(buffer) }) > 0 as i32 as u64 {
            (unsafe {
                evbuffer_add(
                    buffer,
                    b",\0" as *const u8 as *const i8 as *const libc::c_void,
                    1 as i32 as size_t,
                )
            });
        }
        (unsafe { evbuffer_add_printf(buffer, b"%s\0" as *const u8 as *const i8, (*loop_0).name) });
        loop_0 = unsafe { (*loop_0).gentry.tqe_next };
    }
    size = (unsafe { evbuffer_get_length(buffer) }) as i32;
    if size != 0 as i32 {
        (unsafe {
            xasprintf(
                &mut value as *mut *mut i8,
                b"%.*s\0" as *const u8 as *const i8,
                size,
                evbuffer_pullup(buffer, -(1 as i32) as ssize_t),
            )
        });
    }
    (unsafe { evbuffer_free(buffer) });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_session_group_attached_list(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut session = unsafe { (*ft).s };
    let mut client_session: *mut session = std::ptr::null_mut::<session>();
    let mut session_loop: *mut session = std::ptr::null_mut::<session>();
    let mut sg: *mut session_group = std::ptr::null_mut::<session_group>();
    let mut loop_0: *mut client = std::ptr::null_mut::<client>();
    let mut buffer: *mut evbuffer = std::ptr::null_mut::<evbuffer>();
    let mut size: i32 = 0;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if s.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    sg = unsafe { session_group_contains(s) };
    if sg.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    buffer = unsafe { evbuffer_new() };
    if buffer.is_null() {
        (unsafe { fatalx(b"out of memory\0" as *const u8 as *const i8) });
    }
    loop_0 = unsafe { clients.tqh_first };
    while !loop_0.is_null() {
        client_session = unsafe { (*loop_0).session };
        if !client_session.is_null() {
            session_loop = unsafe { (*sg).sessions.tqh_first };
            while !session_loop.is_null() {
                if session_loop == client_session {
                    if (unsafe { evbuffer_get_length(buffer) }) > 0 as i32 as u64 {
                        (unsafe {
                            evbuffer_add(
                                buffer,
                                b",\0" as *const u8 as *const i8 as *const libc::c_void,
                                1 as i32 as size_t,
                            )
                        });
                    }
                    (unsafe {
                        evbuffer_add_printf(
                            buffer,
                            b"%s\0" as *const u8 as *const i8,
                            (*loop_0).name,
                        )
                    });
                }
                session_loop = unsafe { (*session_loop).gentry.tqe_next };
            }
        }
        loop_0 = unsafe { (*loop_0).entry.tqe_next };
    }
    size = (unsafe { evbuffer_get_length(buffer) }) as i32;
    if size != 0 as i32 {
        (unsafe {
            xasprintf(
                &mut value as *mut *mut i8,
                b"%.*s\0" as *const u8 as *const i8,
                size,
                evbuffer_pullup(buffer, -(1 as i32) as ssize_t),
            )
        });
    }
    (unsafe { evbuffer_free(buffer) });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_pane_in_mode(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut n: u_int = 0 as i32 as u_int;
    let mut wme: *mut window_mode_entry = std::ptr::null_mut::<window_mode_entry>();
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    wme = unsafe { (*wp).modes.tqh_first };
    while !wme.is_null() {
        n = n.wrapping_add(1);
        wme = unsafe { (*wme).entry.tqe_next };
    }
    (unsafe {
        xasprintf(
            &mut value as *mut *mut i8,
            b"%u\0" as *const u8 as *const i8,
            n,
        )
    });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_pane_at_top(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut status: i32 = 0;
    let mut flag: i32 = 0;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = unsafe { (*wp).window };
    status = (unsafe {
        options_get_number(
            (*w).options,
            b"pane-border-status\0" as *const u8 as *const i8,
        )
    }) as i32;
    if status == 1 as i32 {
        flag = ((unsafe { (*wp).yoff }) == 1 as i32 as u32) as i32;
    } else {
        flag = ((unsafe { (*wp).yoff }) == 0 as i32 as u32) as i32;
    }
    (unsafe {
        xasprintf(
            &mut value as *mut *mut i8,
            b"%d\0" as *const u8 as *const i8,
            flag,
        )
    });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_pane_at_bottom(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut w: *mut window = std::ptr::null_mut::<window>();
    let mut status: i32 = 0;
    let mut flag: i32 = 0;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    w = unsafe { (*wp).window };
    status = (unsafe {
        options_get_number(
            (*w).options,
            b"pane-border-status\0" as *const u8 as *const i8,
        )
    }) as i32;
    if status == 2 as i32 {
        flag = ((unsafe { (*wp).yoff }).wrapping_add(unsafe { (*wp).sy })
            == (unsafe { (*w).sy }).wrapping_sub(1 as i32 as u32)) as i32;
    } else {
        flag = ((unsafe { (*wp).yoff }).wrapping_add(unsafe { (*wp).sy }) == (unsafe { (*w).sy }))
            as i32;
    }
    (unsafe {
        xasprintf(
            &mut value as *mut *mut i8,
            b"%d\0" as *const u8 as *const i8,
            flag,
        )
    });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_cursor_character(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    (unsafe { grid_view_get_cell((*wp).base.grid, (*wp).base.cx, (*wp).base.cy, &mut gc) });
    if !(gc.flags as i32) & 0x4 as i32 != 0 {
        (unsafe {
            xasprintf(
                &mut value as *mut *mut i8,
                b"%.*s\0" as *const u8 as *const i8,
                gc.data.size as i32,
                (gc.data.data).as_mut_ptr(),
            )
        });
    }
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_mouse_word(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    let mut gd: *mut grid = std::ptr::null_mut::<grid>();
    let mut x: u_int = 0;
    let mut y: u_int = 0;
    if (unsafe { (*ft).m.valid }) == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    wp = unsafe {
        cmd_mouse_pane(
            &mut (*ft).m,
            std::ptr::null_mut::<*mut session>(),
            std::ptr::null_mut::<*mut winlink>(),
        )
    };
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if (unsafe { cmd_mouse_at(wp, &mut (*ft).m, &mut x, &mut y, 0 as i32) }) != 0 as i32 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if !(unsafe { (*wp).modes.tqh_first }).is_null() {
        if (unsafe { window_pane_mode(wp) }) != 0 as i32 {
            return (unsafe { window_copy_get_word(wp, x, y) }) as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    gd = unsafe { (*wp).base.grid };
    return format_grid_word(gd, x, (unsafe { (*gd).hsize }).wrapping_add(y)) as *mut libc::c_void;
}
extern "C" fn format_cb_mouse_hyperlink(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    let mut gd: *mut grid = std::ptr::null_mut::<grid>();
    let mut x: u_int = 0;
    let mut y: u_int = 0;
    if (unsafe { (*ft).m.valid }) == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    wp = unsafe {
        cmd_mouse_pane(
            &mut (*ft).m,
            std::ptr::null_mut::<*mut session>(),
            std::ptr::null_mut::<*mut winlink>(),
        )
    };
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if (unsafe { cmd_mouse_at(wp, &mut (*ft).m, &mut x, &mut y, 0 as i32) }) != 0 as i32 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    gd = unsafe { (*wp).base.grid };
    return format_grid_hyperlink(gd, x, (unsafe { (*gd).hsize }).wrapping_add(y), unsafe {
        (*wp).screen
    }) as *mut libc::c_void;
}
extern "C" fn format_cb_mouse_line(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    let mut gd: *mut grid = std::ptr::null_mut::<grid>();
    let mut x: u_int = 0;
    let mut y: u_int = 0;
    if (unsafe { (*ft).m.valid }) == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    wp = unsafe {
        cmd_mouse_pane(
            &mut (*ft).m,
            std::ptr::null_mut::<*mut session>(),
            std::ptr::null_mut::<*mut winlink>(),
        )
    };
    if wp.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if (unsafe { cmd_mouse_at(wp, &mut (*ft).m, &mut x, &mut y, 0 as i32) }) != 0 as i32 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if !(unsafe { (*wp).modes.tqh_first }).is_null() {
        if (unsafe { window_pane_mode(wp) }) != 0 as i32 {
            return (unsafe { window_copy_get_line(wp, y) }) as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    gd = unsafe { (*wp).base.grid };
    return format_grid_line(gd, (unsafe { (*gd).hsize }).wrapping_add(y)) as *mut libc::c_void;
}
extern "C" fn format_cb_mouse_status_line(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    let mut y: u_int = 0;
    if (unsafe { (*ft).m.valid }) == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if (unsafe { (*ft).c }).is_null() || !(unsafe { (*(*ft).c).tty.flags }) & 0x10 as i32 != 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if (unsafe { (*ft).m.statusat }) == 0 as i32
        && (unsafe { (*ft).m.y }) < (unsafe { (*ft).m.statuslines })
    {
        y = unsafe { (*ft).m.y };
    } else if (unsafe { (*ft).m.statusat }) > 0 as i32
        && (unsafe { (*ft).m.y }) >= (unsafe { (*ft).m.statusat }) as u_int
    {
        y = (unsafe { (*ft).m.y }).wrapping_sub((unsafe { (*ft).m.statusat }) as u32);
    } else {
        return std::ptr::null_mut::<libc::c_void>();
    }
    (unsafe {
        xasprintf(
            &mut value as *mut *mut i8,
            b"%u\0" as *const u8 as *const i8,
            y,
        )
    });
    return value as *mut libc::c_void;
}
extern "C" fn format_cb_mouse_status_range(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut sr: *mut style_range = std::ptr::null_mut::<style_range>();
    let mut x: u_int = 0;
    let mut y: u_int = 0;
    if (unsafe { (*ft).m.valid }) == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if (unsafe { (*ft).c }).is_null() || !(unsafe { (*(*ft).c).tty.flags }) & 0x10 as i32 != 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    if (unsafe { (*ft).m.statusat }) == 0 as i32
        && (unsafe { (*ft).m.y }) < (unsafe { (*ft).m.statuslines })
    {
        x = unsafe { (*ft).m.x };
        y = unsafe { (*ft).m.y };
    } else if (unsafe { (*ft).m.statusat }) > 0 as i32
        && (unsafe { (*ft).m.y }) >= (unsafe { (*ft).m.statusat }) as u_int
    {
        x = unsafe { (*ft).m.x };
        y = (unsafe { (*ft).m.y }).wrapping_sub((unsafe { (*ft).m.statusat }) as u32);
    } else {
        return std::ptr::null_mut::<libc::c_void>();
    }
    sr = unsafe { status_get_range((*ft).c, x, y) };
    if sr.is_null() {
        return std::ptr::null_mut::<libc::c_void>();
    }
    match (unsafe { (*sr).type_0 }) as u32 {
        0 => return std::ptr::null_mut::<libc::c_void>(),
        1 => {
            return (unsafe { xstrdup(b"left\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        2 => {
            return (unsafe { xstrdup(b"right\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        3 => {
            return (unsafe { xstrdup(b"pane\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        4 => {
            return (unsafe { xstrdup(b"window\0" as *const u8 as *const i8) })
                as *mut libc::c_void;
        }
        5 => {
            return (unsafe { xstrdup(b"session\0" as *const u8 as *const i8) })
                as *mut libc::c_void;
        }
        6 => return (unsafe { xstrdup(((*sr).string).as_mut_ptr()) }) as *mut libc::c_void,
        _ => {}
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_alternate_on(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if !(unsafe { (*(*ft).wp).base.saved_grid }).is_null() {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_alternate_saved_x(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe {
            format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).wp).base.saved_cx)
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_alternate_saved_y(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe {
            format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).wp).base.saved_cy)
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_buffer_name(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).pb }).is_null() {
        return (unsafe { xstrdup(paste_buffer_name((*ft).pb)) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_buffer_sample(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).pb }).is_null() {
        return (unsafe { paste_make_sample((*ft).pb) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_buffer_size(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut size: size_t = 0;
    if !(unsafe { (*ft).pb }).is_null() {
        (unsafe { paste_buffer_data((*ft).pb, &mut size) });
        return (unsafe { format_printf(b"%zu\0" as *const u8 as *const i8, size) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_cell_height(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() && (unsafe { (*(*ft).c).tty.flags }) & 0x10 as i32 != 0 {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).c).tty.ypixel) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_cell_width(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() && (unsafe { (*(*ft).c).tty.flags }) & 0x10 as i32 != 0 {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).c).tty.xpixel) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_control_mode(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        if (unsafe { (*(*ft).c).flags }) & 0x2000 as i32 as u64 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_discarded(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        return (unsafe { format_printf(b"%zu\0" as *const u8 as *const i8, (*(*ft).c).discarded) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_flags(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        return (unsafe { xstrdup(server_client_get_flags((*ft).c)) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_height(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() && (unsafe { (*(*ft).c).tty.flags }) & 0x10 as i32 != 0 {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).c).tty.sy) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_key_table(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        return (unsafe { xstrdup((*(*(*ft).c).keytable).name) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_last_session(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null()
        && !(unsafe { (*(*ft).c).last_session }).is_null()
        && (unsafe { session_alive((*(*ft).c).last_session) }) != 0
    {
        return (unsafe { xstrdup((*(*(*ft).c).last_session).name) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_name(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        return (unsafe { xstrdup((*(*ft).c).name) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_pid(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        return (unsafe { format_printf(b"%ld\0" as *const u8 as *const i8, (*(*ft).c).pid as i64) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_prefix(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut name: *const i8 = std::ptr::null::<i8>();
    if !(unsafe { (*ft).c }).is_null() {
        name = unsafe { server_client_get_key_table((*ft).c) };
        if (unsafe { strcmp((*(*(*ft).c).keytable).name, name) }) == 0 as i32 {
            return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_readonly(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        if (unsafe { (*(*ft).c).flags }) & 0x800 as i32 as u64 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_session(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() && !(unsafe { (*(*ft).c).session }).is_null() {
        return (unsafe { xstrdup((*(*(*ft).c).session).name) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_termfeatures(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        return (unsafe { xstrdup(tty_get_features((*(*ft).c).term_features)) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_termname(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        return (unsafe { xstrdup((*(*ft).c).term_name) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_termtype(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        if (unsafe { (*(*ft).c).term_type }).is_null() {
            return (unsafe { xstrdup(b"\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup((*(*ft).c).term_type) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_tty(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        return (unsafe { xstrdup((*(*ft).c).ttyname) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_uid(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut uid: uid_t = 0;
    if !(unsafe { (*ft).c }).is_null() {
        uid = unsafe { proc_get_peer_uid((*(*ft).c).peer) };
        if uid != -(1 as i32) as uid_t {
            return (unsafe { format_printf(b"%ld\0" as *const u8 as *const i8, uid as i64) })
                as *mut libc::c_void;
        }
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_user(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut uid: uid_t = 0;
    let mut pw: *mut passwd = std::ptr::null_mut::<passwd>();
    if !(unsafe { (*ft).c }).is_null() {
        uid = unsafe { proc_get_peer_uid((*(*ft).c).peer) };
        if uid != -(1 as i32) as uid_t && {
            pw = unsafe { getpwuid(uid) };
            !pw.is_null()
        } {
            return (unsafe { xstrdup((*pw).pw_name) }) as *mut libc::c_void;
        }
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_utf8(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        if (unsafe { (*(*ft).c).flags }) & 0x10000 as i32 as u64 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_width(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).c).tty.sx) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_written(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        return (unsafe { format_printf(b"%zu\0" as *const u8 as *const i8, (*(*ft).c).written) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_config_files(mut _ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut i8 = std::ptr::null_mut::<i8>();
    let mut slen: size_t = 0 as i32 as size_t;
    let mut i: u_int = 0;
    let mut n: size_t = 0;
    i = 0 as i32 as u_int;
    while i < (unsafe { cfg_nfiles }) {
        n = (unsafe { strlen(*cfg_files.offset(i as isize)) }).wrapping_add(1 as i32 as u64);
        s = (unsafe {
            xrealloc(
                s as *mut libc::c_void,
                slen.wrapping_add(n).wrapping_add(1 as i32 as u64),
            )
        }) as *mut i8;
        slen = (slen as u64).wrapping_add(
            (unsafe {
                xsnprintf(
                    s.offset(slen as isize),
                    n.wrapping_add(1 as i32 as u64),
                    b"%s,\0" as *const u8 as *const i8,
                    *cfg_files.offset(i as isize),
                )
            }) as u64,
        ) as size_t as size_t;
        i = i.wrapping_add(1);
    }
    if s.is_null() {
        return (unsafe { xstrdup(b"\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    (unsafe { *s.offset(slen.wrapping_sub(1 as i32 as u64) as isize) = '\0' as i32 as i8 });
    return s as *mut libc::c_void;
}
extern "C" fn format_cb_cursor_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.mode }) & 0x1 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_cursor_x(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).wp).base.cx) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_cursor_y(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).wp).base.cy) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_history_limit(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe {
            format_printf(
                b"%u\0" as *const u8 as *const i8,
                (*(*(*ft).wp).base.grid).hlimit,
            )
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_history_size(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe {
            format_printf(
                b"%u\0" as *const u8 as *const i8,
                (*(*(*ft).wp).base.grid).hsize,
            )
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_insert_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.mode }) & 0x2 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_keypad_cursor_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.mode }) & 0x4 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_keypad_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.mode }) & 0x8 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_mouse_all_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.mode }) & 0x1000 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_mouse_any_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.mode }) & (0x20 as i32 | 0x40 as i32 | 0x1000 as i32) != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_mouse_button_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.mode }) & 0x40 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_mouse_pane(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    if (unsafe { (*ft).m.valid }) != 0 {
        wp = unsafe {
            cmd_mouse_pane(
                &mut (*ft).m,
                std::ptr::null_mut::<*mut session>(),
                std::ptr::null_mut::<*mut winlink>(),
            )
        };
        if !wp.is_null() {
            return (unsafe { format_printf(b"%%%u\0" as *const u8 as *const i8, (*wp).id) })
                as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_mouse_sgr_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.mode }) & 0x200 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_mouse_standard_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.mode }) & 0x20 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_mouse_utf8_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.mode }) & 0x100 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_mouse_x(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    let mut x: u_int = 0;
    let mut y: u_int = 0;
    if (unsafe { (*ft).m.valid }) == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    wp = unsafe {
        cmd_mouse_pane(
            &mut (*ft).m,
            std::ptr::null_mut::<*mut session>(),
            std::ptr::null_mut::<*mut winlink>(),
        )
    };
    if !wp.is_null()
        && (unsafe { cmd_mouse_at(wp, &mut (*ft).m, &mut x, &mut y, 0 as i32) }) == 0 as i32
    {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, x) })
            as *mut libc::c_void;
    }
    if !(unsafe { (*ft).c }).is_null() && (unsafe { (*(*ft).c).tty.flags }) & 0x10 as i32 != 0 {
        if (unsafe { (*ft).m.statusat }) == 0 as i32
            && (unsafe { (*ft).m.y }) < (unsafe { (*ft).m.statuslines })
        {
            return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*ft).m.x) })
                as *mut libc::c_void;
        }
        if (unsafe { (*ft).m.statusat }) > 0 as i32
            && (unsafe { (*ft).m.y }) >= (unsafe { (*ft).m.statusat }) as u_int
        {
            return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*ft).m.x) })
                as *mut libc::c_void;
        }
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_mouse_y(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    let mut x: u_int = 0;
    let mut y: u_int = 0;
    if (unsafe { (*ft).m.valid }) == 0 {
        return std::ptr::null_mut::<libc::c_void>();
    }
    wp = unsafe {
        cmd_mouse_pane(
            &mut (*ft).m,
            std::ptr::null_mut::<*mut session>(),
            std::ptr::null_mut::<*mut winlink>(),
        )
    };
    if !wp.is_null()
        && (unsafe { cmd_mouse_at(wp, &mut (*ft).m, &mut x, &mut y, 0 as i32) }) == 0 as i32
    {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, y) })
            as *mut libc::c_void;
    }
    if !(unsafe { (*ft).c }).is_null() && (unsafe { (*(*ft).c).tty.flags }) & 0x10 as i32 != 0 {
        if (unsafe { (*ft).m.statusat }) == 0 as i32
            && (unsafe { (*ft).m.y }) < (unsafe { (*ft).m.statuslines })
        {
            return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*ft).m.y) })
                as *mut libc::c_void;
        }
        if (unsafe { (*ft).m.statusat }) > 0 as i32
            && (unsafe { (*ft).m.y }) >= (unsafe { (*ft).m.statusat }) as u_int
        {
            return (unsafe {
                format_printf(
                    b"%u\0" as *const u8 as *const i8,
                    ((*ft).m.y).wrapping_sub((*ft).m.statusat as u32),
                )
            }) as *mut libc::c_void;
        }
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_next_session_id(mut _ft: *mut format_tree) -> *mut libc::c_void {
    return (unsafe { format_printf(b"$%u\0" as *const u8 as *const i8, next_session_id) })
        as *mut libc::c_void;
}
extern "C" fn format_cb_origin_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.mode }) & 0x2000 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_active(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*ft).wp }) == (unsafe { (*(*(*ft).wp).window).active }) {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_at_left(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).xoff }) == 0 as i32 as u32 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_at_right(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).xoff }).wrapping_add(unsafe { (*(*ft).wp).sx })
            == (unsafe { (*(*(*ft).wp).window).sx })
        {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_bottom(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe {
            format_printf(
                b"%u\0" as *const u8 as *const i8,
                ((*(*ft).wp).yoff)
                    .wrapping_add((*(*ft).wp).sy)
                    .wrapping_sub(1 as i32 as u32),
            )
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_dead(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).fd }) == -(1 as i32) {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_dead_signal(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut name: *const i8 = std::ptr::null::<i8>();
    if !wp.is_null() {
        if (unsafe { (*wp).flags }) & 0x200 as i32 != 0
            && (((unsafe { (*wp).status }) & 0x7f as i32) + 1 as i32) as i8 as i32 >> 1 as i32
                > 0 as i32
        {
            name = unsafe { sig2name((*wp).status & 0x7f as i32) };
            return (unsafe { format_printf(b"%s\0" as *const u8 as *const i8, name) })
                as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_dead_status(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    if !wp.is_null() {
        if (unsafe { (*wp).flags }) & 0x200 as i32 != 0
            && (unsafe { (*wp).status }) & 0x7f as i32 == 0 as i32
        {
            return (unsafe {
                format_printf(
                    b"%d\0" as *const u8 as *const i8,
                    ((*wp).status & 0xff00 as i32) >> 8 as i32,
                )
            }) as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_dead_time(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    if !wp.is_null() {
        if (unsafe { (*wp).flags }) & 0x400 as i32 != 0 {
            return (unsafe { &mut (*wp).dead_time }) as *mut timeval as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_format(mut ft: *mut format_tree) -> *mut libc::c_void {
    if (unsafe { (*ft).type_0 }) as u32 == FORMAT_TYPE_PANE as i32 as u32 {
        return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
}
extern "C" fn format_cb_pane_height(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).wp).sy) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_id(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe { format_printf(b"%%%u\0" as *const u8 as *const i8, (*(*ft).wp).id) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_index(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut idx: u_int = 0;
    if !(unsafe { (*ft).wp }).is_null()
        && (unsafe { window_pane_index((*ft).wp, &mut idx) }) == 0 as i32
    {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, idx) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_input_off(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).flags }) & 0x40 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_unseen_changes(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).flags }) & 0x2000 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_key_mode(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() && !(unsafe { (*(*ft).wp).screen }).is_null() {
        match (unsafe { (*(*(*ft).wp).screen).mode }) & (0x8000 as i32 | 0x40000 as i32) {
            32768 => {
                return (unsafe { xstrdup(b"Ext 1\0" as *const u8 as *const i8) })
                    as *mut libc::c_void;
            }
            262144 => {
                return (unsafe { xstrdup(b"Ext 2\0" as *const u8 as *const i8) })
                    as *mut libc::c_void;
            }
            _ => {
                return (unsafe { xstrdup(b"VT10x\0" as *const u8 as *const i8) })
                    as *mut libc::c_void;
            }
        }
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_last(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*ft).wp }) == (unsafe { (*(*(*ft).wp).window).last_panes.tqh_first }) {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_left(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).wp).xoff) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_marked(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { server_check_marked() }) != 0
            && (unsafe { marked_pane.wp }) == (unsafe { (*ft).wp })
        {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_marked_set(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { server_check_marked() }) != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_mode(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wme: *mut window_mode_entry = std::ptr::null_mut::<window_mode_entry>();
    if !(unsafe { (*ft).wp }).is_null() {
        wme = unsafe { (*(*ft).wp).modes.tqh_first };
        if !wme.is_null() {
            return (unsafe { xstrdup((*(*wme).mode).name) }) as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_path(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.path }).is_null() {
            return (unsafe { xstrdup(b"\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup((*(*ft).wp).base.path) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_pid(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe {
            format_printf(b"%ld\0" as *const u8 as *const i8, (*(*ft).wp).pid as i64)
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_pipe(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).pipe_fd }) != -(1 as i32) {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_right(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe {
            format_printf(
                b"%u\0" as *const u8 as *const i8,
                ((*(*ft).wp).xoff)
                    .wrapping_add((*(*ft).wp).sx)
                    .wrapping_sub(1 as i32 as u32),
            )
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_search_string(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).searchstr }).is_null() {
            return (unsafe { xstrdup(b"\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup((*(*ft).wp).searchstr) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_synchronized(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe {
            options_get_number(
                (*(*ft).wp).options,
                b"synchronize-panes\0" as *const u8 as *const i8,
            )
        }) != 0
        {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_title(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe { xstrdup((*(*ft).wp).base.title) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_top(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).wp).yoff) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_tty(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe { xstrdup(((*(*ft).wp).tty).as_mut_ptr()) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_pane_width(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).wp).sx) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_scroll_region_lower(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe {
            format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).wp).base.rlower)
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_scroll_region_upper(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        return (unsafe {
            format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).wp).base.rupper)
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_server_sessions(mut _ft: *mut format_tree) -> *mut libc::c_void {
    let mut s: *mut session = std::ptr::null_mut::<session>();
    let mut n: u_int = 0 as i32 as u_int;
    s = unsafe { sessions_RB_MINMAX(&mut sessions, -(1 as i32)) };
    while !s.is_null() {
        n = n.wrapping_add(1);
        s = unsafe { sessions_RB_NEXT(s) };
    }
    return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, n) }) as *mut libc::c_void;
}
extern "C" fn format_cb_session_attached(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).s }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).s).attached) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_format(mut ft: *mut format_tree) -> *mut libc::c_void {
    if (unsafe { (*ft).type_0 }) as u32 == FORMAT_TYPE_SESSION as i32 as u32 {
        return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
}
extern "C" fn format_cb_session_group(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut sg: *mut session_group = std::ptr::null_mut::<session_group>();
    if !(unsafe { (*ft).s }).is_null() && {
        sg = unsafe { session_group_contains((*ft).s) };
        !sg.is_null()
    } {
        return (unsafe { xstrdup((*sg).name) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_group_attached(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut sg: *mut session_group = std::ptr::null_mut::<session_group>();
    if !(unsafe { (*ft).s }).is_null() && {
        sg = unsafe { session_group_contains((*ft).s) };
        !sg.is_null()
    } {
        return (unsafe {
            format_printf(
                b"%u\0" as *const u8 as *const i8,
                session_group_attached_count(sg),
            )
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_group_many_attached(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut sg: *mut session_group = std::ptr::null_mut::<session_group>();
    if !(unsafe { (*ft).s }).is_null() && {
        sg = unsafe { session_group_contains((*ft).s) };
        !sg.is_null()
    } {
        if (unsafe { session_group_attached_count(sg) }) > 1 as i32 as u32 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_group_size(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut sg: *mut session_group = std::ptr::null_mut::<session_group>();
    if !(unsafe { (*ft).s }).is_null() && {
        sg = unsafe { session_group_contains((*ft).s) };
        !sg.is_null()
    } {
        return (unsafe {
            format_printf(b"%u\0" as *const u8 as *const i8, session_group_count(sg))
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_grouped(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).s }).is_null() {
        if !(unsafe { session_group_contains((*ft).s) }).is_null() {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_id(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).s }).is_null() {
        return (unsafe { format_printf(b"$%u\0" as *const u8 as *const i8, (*(*ft).s).id) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_many_attached(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).s }).is_null() {
        if (unsafe { (*(*ft).s).attached }) > 1 as i32 as u32 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_marked(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).s }).is_null() {
        if (unsafe { server_check_marked() }) != 0
            && (unsafe { marked_pane.s }) == (unsafe { (*ft).s })
        {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_name(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).s }).is_null() {
        return (unsafe { xstrdup((*(*ft).s).name) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_path(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).s }).is_null() {
        return (unsafe { xstrdup((*(*ft).s).cwd) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_windows(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).s }).is_null() {
        return (unsafe {
            format_printf(
                b"%u\0" as *const u8 as *const i8,
                winlink_count(&mut (*(*ft).s).windows),
            )
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_socket_path(mut _ft: *mut format_tree) -> *mut libc::c_void {
    return (unsafe { xstrdup(socket_path) }) as *mut libc::c_void;
}
extern "C" fn format_cb_version(mut _ft: *mut format_tree) -> *mut libc::c_void {
    return (unsafe { xstrdup(getversion()) }) as *mut libc::c_void;
}
extern "C" fn format_cb_sixel_support(mut _ft: *mut format_tree) -> *mut libc::c_void {
    return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
}
extern "C" fn format_cb_active_window_index(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).s }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*(*ft).s).curw).idx) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_last_window_index(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    if !(unsafe { (*ft).s }).is_null() {
        wl = unsafe { winlinks_RB_MINMAX(&mut (*(*ft).s).windows, 1 as i32) };
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*wl).idx) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_active(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        if (unsafe { (*ft).wl }) == (unsafe { (*(*(*ft).wl).session).curw }) {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_activity_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        if (unsafe { (*(*ft).wl).flags }) & 0x2 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_bell_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        if (unsafe { (*(*ft).wl).flags }) & 0x1 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_bigger(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut ox: u_int = 0;
    let mut oy: u_int = 0;
    let mut sx: u_int = 0;
    let mut sy: u_int = 0;
    if !(unsafe { (*ft).c }).is_null() {
        if (unsafe { tty_window_offset(&mut (*(*ft).c).tty, &mut ox, &mut oy, &mut sx, &mut sy) })
            != 0
        {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_cell_height(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).w }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).w).ypixel) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_cell_width(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).w }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).w).xpixel) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_end_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        if (unsafe { (*ft).wl })
            == (unsafe { winlinks_RB_MINMAX(&mut (*(*(*ft).wl).session).windows, 1 as i32) })
        {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_flags(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        return (unsafe { xstrdup(window_printable_flags((*ft).wl, 1 as i32)) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_format(mut ft: *mut format_tree) -> *mut libc::c_void {
    if (unsafe { (*ft).type_0 }) as u32 == FORMAT_TYPE_WINDOW as i32 as u32 {
        return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
}
extern "C" fn format_cb_window_height(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).w }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).w).sy) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_id(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).w }).is_null() {
        return (unsafe { format_printf(b"@%u\0" as *const u8 as *const i8, (*(*ft).w).id) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_index(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        return (unsafe { format_printf(b"%d\0" as *const u8 as *const i8, (*(*ft).wl).idx) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_last_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        if (unsafe { (*ft).wl }) == (unsafe { (*(*(*ft).wl).session).lastw.tqh_first }) {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_linked(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        if (unsafe { session_is_linked((*(*ft).wl).session, (*(*ft).wl).window) }) != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_linked_sessions(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        return (unsafe {
            format_printf(
                b"%u\0" as *const u8 as *const i8,
                (*(*(*ft).wl).window).references,
            )
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_marked_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        if (unsafe { server_check_marked() }) != 0
            && (unsafe { marked_pane.wl }) == (unsafe { (*ft).wl })
        {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_name(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).w }).is_null() {
        return (unsafe { format_printf(b"%s\0" as *const u8 as *const i8, (*(*ft).w).name) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_offset_x(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut ox: u_int = 0;
    let mut oy: u_int = 0;
    let mut sx: u_int = 0;
    let mut sy: u_int = 0;
    if !(unsafe { (*ft).c }).is_null() {
        if (unsafe { tty_window_offset(&mut (*(*ft).c).tty, &mut ox, &mut oy, &mut sx, &mut sy) })
            != 0
        {
            return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, ox) })
                as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_offset_y(mut ft: *mut format_tree) -> *mut libc::c_void {
    let mut ox: u_int = 0;
    let mut oy: u_int = 0;
    let mut sx: u_int = 0;
    let mut sy: u_int = 0;
    if !(unsafe { (*ft).c }).is_null() {
        if (unsafe { tty_window_offset(&mut (*(*ft).c).tty, &mut ox, &mut oy, &mut sx, &mut sy) })
            != 0
        {
            return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, oy) })
                as *mut libc::c_void;
        }
        return std::ptr::null_mut::<libc::c_void>();
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_panes(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).w }).is_null() {
        return (unsafe {
            format_printf(
                b"%u\0" as *const u8 as *const i8,
                window_count_panes((*ft).w),
            )
        }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_raw_flags(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        return (unsafe { xstrdup(window_printable_flags((*ft).wl, 0 as i32)) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_silence_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        if (unsafe { (*(*ft).wl).flags }) & 0x4 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_start_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wl }).is_null() {
        if (unsafe { (*ft).wl })
            == (unsafe { winlinks_RB_MINMAX(&mut (*(*(*ft).wl).session).windows, -(1 as i32)) })
        {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_width(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).w }).is_null() {
        return (unsafe { format_printf(b"%u\0" as *const u8 as *const i8, (*(*ft).w).sx) })
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_window_zoomed_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).w }).is_null() {
        if (unsafe { (*(*ft).w).flags }) & 0x8 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_wrap_flag(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).wp }).is_null() {
        if (unsafe { (*(*ft).wp).base.mode }) & 0x10 as i32 != 0 {
            return (unsafe { xstrdup(b"1\0" as *const u8 as *const i8) }) as *mut libc::c_void;
        }
        return (unsafe { xstrdup(b"0\0" as *const u8 as *const i8) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_buffer_created(mut ft: *mut format_tree) -> *mut libc::c_void {
    static mut tv: timeval = timeval {
        tv_sec: 0,
        tv_usec: 0,
    };
    if !(unsafe { (*ft).pb }).is_null() {
        (unsafe { tv.tv_usec = 0 as i32 as __suseconds_t });
        (unsafe { tv.tv_sec = tv.tv_usec });
        (unsafe { tv.tv_sec = paste_buffer_created((*ft).pb) });
        return (unsafe { &mut tv }) as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_activity(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        return (unsafe { &mut (*(*ft).c).activity_time }) as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_client_created(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).c }).is_null() {
        return (unsafe { &mut (*(*ft).c).creation_time }) as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_activity(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).s }).is_null() {
        return (unsafe { &mut (*(*ft).s).activity_time }) as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_created(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).s }).is_null() {
        return (unsafe { &mut (*(*ft).s).creation_time }) as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_session_last_attached(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).s }).is_null() {
        return (unsafe { &mut (*(*ft).s).last_attached_time }) as *mut timeval
            as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_start_time(mut _ft: *mut format_tree) -> *mut libc::c_void {
    return (unsafe { &mut start_time }) as *mut timeval as *mut libc::c_void;
}
extern "C" fn format_cb_window_activity(mut ft: *mut format_tree) -> *mut libc::c_void {
    if !(unsafe { (*ft).w }).is_null() {
        return (unsafe { &mut (*(*ft).w).activity_time }) as *mut timeval as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
extern "C" fn format_cb_buffer_mode_format(mut _ft: *mut format_tree) -> *mut libc::c_void {
    return (unsafe { xstrdup(window_buffer_mode.default_format) }) as *mut libc::c_void;
}
extern "C" fn format_cb_client_mode_format(mut _ft: *mut format_tree) -> *mut libc::c_void {
    return (unsafe { xstrdup(window_client_mode.default_format) }) as *mut libc::c_void;
}
extern "C" fn format_cb_tree_mode_format(mut _ft: *mut format_tree) -> *mut libc::c_void {
    return (unsafe { xstrdup(window_tree_mode.default_format) }) as *mut libc::c_void;
}
extern "C" fn format_cb_uid(mut _ft: *mut format_tree) -> *mut libc::c_void {
    return (unsafe { format_printf(b"%ld\0" as *const u8 as *const i8, getuid() as i64) })
        as *mut libc::c_void;
}
extern "C" fn format_cb_user(mut _ft: *mut format_tree) -> *mut libc::c_void {
    let mut pw: *mut passwd = std::ptr::null_mut::<passwd>();
    pw = unsafe { getpwuid(getuid()) };
    if !pw.is_null() {
        return (unsafe { xstrdup((*pw).pw_name) }) as *mut libc::c_void;
    }
    return std::ptr::null_mut::<libc::c_void>();
}
static mut format_table: [format_table_entry; 172] = {
    [
        {
            let mut init = format_table_entry {
                key: b"active_window_index\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_active_window_index
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"alternate_on\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_alternate_on
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"alternate_saved_x\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_alternate_saved_x
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"alternate_saved_y\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_alternate_saved_y
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"buffer_created\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_buffer_created
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"buffer_mode_format\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_buffer_mode_format
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"buffer_name\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_buffer_name
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"buffer_sample\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_buffer_sample
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"buffer_size\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_buffer_size
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_activity\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_client_activity
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_cell_height\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_cell_height
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_cell_width\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_cell_width
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_control_mode\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_control_mode
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_created\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_client_created
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_discarded\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_discarded
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_flags\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_flags
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_height\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_height
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_key_table\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_key_table
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_last_session\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_last_session
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_mode_format\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_mode_format
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_name\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_name
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_pid\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_pid
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_prefix\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_prefix
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_readonly\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_readonly
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_session\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_session
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_termfeatures\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_termfeatures
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_termname\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_termname
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_termtype\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_termtype
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_tty\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_tty
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_uid\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_uid
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_user\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_user
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_utf8\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_utf8
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_width\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_width
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"client_written\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_client_written
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"config_files\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_config_files
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"cursor_character\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_cursor_character
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"cursor_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_cursor_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"cursor_x\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_cursor_x
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"cursor_y\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_cursor_y
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"history_all_bytes\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_history_all_bytes
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"history_bytes\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_history_bytes
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"history_limit\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_history_limit
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"history_size\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_history_size
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"host\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_host as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"host_short\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_host_short
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"insert_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_insert_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"keypad_cursor_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_keypad_cursor_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"keypad_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_keypad_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"last_window_index\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_last_window_index
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_all_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_all_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_any_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_any_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_button_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_button_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_hyperlink\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_hyperlink
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_line\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_line
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_pane\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_pane
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_sgr_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_sgr_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_standard_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_standard_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_status_line\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_status_line
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_status_range\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_status_range
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_utf8_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_utf8_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_word\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_word
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_x\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_x
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"mouse_y\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_mouse_y
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"next_session_id\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_next_session_id
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"origin_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_origin_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_active\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_active
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_at_bottom\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_at_bottom
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_at_left\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_at_left
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_at_right\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_at_right
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_at_top\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_at_top
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_bg\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_bg
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_bottom\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_bottom
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_current_command\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_current_command
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_current_path\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_current_path
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_dead\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_dead
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_dead_signal\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_dead_signal
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_dead_status\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_dead_status
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_dead_time\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_pane_dead_time
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_fg\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_fg
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_format\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_format
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_height\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_height
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_id\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_id
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_in_mode\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_in_mode
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_index\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_index
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_input_off\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_input_off
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_key_mode\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_key_mode
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_last\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_last
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_left\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_left
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_marked\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_marked
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_marked_set\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_marked_set
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_mode\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_mode
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_path\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_path
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_pid\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_pid
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_pipe\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_pipe
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_right\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_right
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_search_string\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_search_string
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_start_command\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_start_command
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_start_path\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_start_path
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_synchronized\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_synchronized
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_tabs\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_tabs
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_title\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_title
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_top\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_top
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_tty\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_tty
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_unseen_changes\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_unseen_changes
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pane_width\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pane_width
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"pid\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_pid as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"scroll_region_lower\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_scroll_region_lower
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"scroll_region_upper\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_scroll_region_upper
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"server_sessions\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_server_sessions
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_activity\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_session_activity
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_alerts\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_alerts
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_attached\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_attached
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_attached_list\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_attached_list
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_created\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_session_created
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_format\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_format
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_group\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_group
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_group_attached\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_group_attached
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_group_attached_list\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_group_attached_list
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_group_list\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_group_list
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_group_many_attached\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_group_many_attached
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_group_size\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_group_size
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_grouped\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_grouped
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_id\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_id
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_last_attached\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_session_last_attached
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_many_attached\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_many_attached
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_marked\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_marked
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_name\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_name
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_path\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_path
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_stack\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_stack
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"session_windows\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_session_windows
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"sixel_support\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_sixel_support
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"socket_path\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_socket_path
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"start_time\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_start_time
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"tree_mode_format\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_tree_mode_format
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"uid\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_uid as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"user\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_user as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"version\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_version
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_active\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_active
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_active_clients\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_active_clients
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_active_clients_list\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_active_clients_list
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_active_sessions\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_active_sessions
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_active_sessions_list\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_active_sessions_list
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_activity\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_TIME,
                cb: Some(
                    format_cb_window_activity
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_activity_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_activity_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_bell_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_bell_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_bigger\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_bigger
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_cell_height\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_cell_height
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_cell_width\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_cell_width
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_end_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_end_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_flags\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_flags
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_format\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_format
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_height\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_height
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_id\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_id
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_index\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_index
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_last_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_last_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_layout\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_layout
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_linked\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_linked
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_linked_sessions\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_linked_sessions
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_linked_sessions_list\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_linked_sessions_list
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_marked_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_marked_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_name\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_name
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_offset_x\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_offset_x
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_offset_y\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_offset_y
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_panes\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_panes
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_raw_flags\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_raw_flags
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_silence_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_silence_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_stack_index\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_stack_index
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_start_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_start_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_visible_layout\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_visible_layout
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_width\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_width
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"window_zoomed_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_window_zoomed_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
        {
            let mut init = format_table_entry {
                key: b"wrap_flag\0" as *const u8 as *const i8,
                type_0: FORMAT_TABLE_STRING,
                cb: Some(
                    format_cb_wrap_flag
                        as unsafe extern "C" fn(*mut format_tree) -> *mut libc::c_void,
                ),
            };
            init
        },
    ]
};
extern "C" fn format_table_compare(
    mut key0: *const libc::c_void,
    mut entry0: *const libc::c_void,
) -> i32 {
    let mut key: *const i8 = key0 as *const i8;
    let mut entry: *const format_table_entry = entry0 as *const format_table_entry;
    return unsafe { strcmp(key, (*entry).key) };
}
extern "C" fn format_table_get(mut key: *const i8) -> *mut format_table_entry {
    return (unsafe {
        bsearch(
            key as *const libc::c_void,
            format_table.as_ptr() as *const libc::c_void,
            (::core::mem::size_of::<[format_table_entry; 172]>() as u64)
                .wrapping_div(::core::mem::size_of::<format_table_entry>() as u64),
            ::core::mem::size_of::<format_table_entry>() as u64,
            Some(
                format_table_compare
                    as unsafe extern "C" fn(*const libc::c_void, *const libc::c_void) -> i32,
            ),
        )
    }) as *mut format_table_entry;
}
#[no_mangle]
pub extern "C" fn format_merge(mut ft: *mut format_tree, mut from: *mut format_tree) {
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    fe = format_entry_tree_RB_MINMAX(unsafe { &mut (*from).tree }, -(1 as i32));
    while !fe.is_null() {
        if !(unsafe { (*fe).value }).is_null() {
            (unsafe {
                format_add(
                    ft,
                    (*fe).key,
                    b"%s\0" as *const u8 as *const i8,
                    (*fe).value,
                )
            });
        }
        fe = format_entry_tree_RB_NEXT(fe);
    }
}
#[no_mangle]
pub extern "C" fn format_get_pane(mut ft: *mut format_tree) -> *mut window_pane {
    return unsafe { (*ft).wp };
}
extern "C" fn format_create_add_item(mut ft: *mut format_tree, mut item: *mut cmdq_item) {
    let mut event: *mut key_event = unsafe { cmdq_get_event(item) };
    let mut m: *mut mouse_event = unsafe { &mut (*event).m };
    (unsafe { cmdq_merge_formats(item, ft) });
    (unsafe {
        memcpy(
            &mut (*ft).m as *mut mouse_event as *mut libc::c_void,
            m as *const libc::c_void,
            ::core::mem::size_of::<mouse_event>() as u64,
        )
    });
}
#[no_mangle]
pub extern "C" fn format_create(
    mut c: *mut client,
    mut item: *mut cmdq_item,
    mut tag: i32,
    mut flags: i32,
) -> *mut format_tree {
    let mut ft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    ft = (unsafe {
        xcalloc(
            1 as i32 as size_t,
            ::core::mem::size_of::<format_tree>() as u64,
        )
    }) as *mut format_tree;
    (unsafe { (*ft).tree.rbh_root = std::ptr::null_mut::<format_entry>() });
    if !c.is_null() {
        (unsafe { (*ft).client = c });
        (unsafe { (*(*ft).client).references += 1 });
    }
    (unsafe { (*ft).item = item });
    (unsafe { (*ft).tag = tag as u_int });
    (unsafe { (*ft).flags = flags });
    if !item.is_null() {
        format_create_add_item(ft, item);
    }
    return ft;
}
#[no_mangle]
pub extern "C" fn format_free(mut ft: *mut format_tree) {
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut fe1: *mut format_entry = std::ptr::null_mut::<format_entry>();
    fe = format_entry_tree_RB_MINMAX(unsafe { &mut (*ft).tree }, -(1 as i32));
    while !fe.is_null() && {
        fe1 = format_entry_tree_RB_NEXT(fe);
        1 as i32 != 0
    } {
        format_entry_tree_RB_REMOVE(unsafe { &mut (*ft).tree }, fe);
        (unsafe { free((*fe).value as *mut libc::c_void) });
        (unsafe { free((*fe).key as *mut libc::c_void) });
        (unsafe { free(fe as *mut libc::c_void) });
        fe = fe1;
    }
    if !(unsafe { (*ft).client }).is_null() {
        (unsafe { server_client_unref((*ft).client) });
    }
    (unsafe { free(ft as *mut libc::c_void) });
}
extern "C" fn format_log_debug_cb(
    mut key: *const i8,
    mut value: *const i8,
    mut arg: *mut libc::c_void,
) {
    let mut prefix: *const i8 = arg as *const i8;
    (unsafe { log_debug(b"%s: %s=%s\0" as *const u8 as *const i8, prefix, key, value) });
}
#[no_mangle]
pub extern "C" fn format_log_debug(mut ft: *mut format_tree, mut prefix: *const i8) {
    format_each(
        ft,
        Some(
            format_log_debug_cb
                as unsafe extern "C" fn(*const i8, *const i8, *mut libc::c_void) -> (),
        ),
        prefix as *mut libc::c_void,
    );
}
#[no_mangle]
pub extern "C" fn format_each(
    mut ft: *mut format_tree,
    mut cb: Option<unsafe extern "C" fn(*const i8, *const i8, *mut libc::c_void) -> ()>,
    mut arg: *mut libc::c_void,
) {
    let mut fte: *const format_table_entry = std::ptr::null::<format_table_entry>();
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut i: u_int = 0;
    let mut s: [i8; 64] = [0; 64];
    let mut value: *mut libc::c_void = std::ptr::null_mut::<libc::c_void>();
    let mut tv: *mut timeval = std::ptr::null_mut::<timeval>();
    i = 0 as i32 as u_int;
    while (i as u64)
        < (::core::mem::size_of::<[format_table_entry; 172]>() as u64)
            .wrapping_div(::core::mem::size_of::<format_table_entry>() as u64)
    {
        fte = (unsafe { &*format_table.as_ptr().offset(i as isize) }) as *const format_table_entry;
        value = unsafe { ((*fte).cb).expect("non-null function pointer")(ft) };
        if !value.is_null() {
            if (unsafe { (*fte).type_0 }) as u32 == FORMAT_TABLE_TIME as i32 as u32 {
                tv = value as *mut timeval;
                (unsafe {
                    xsnprintf(
                        s.as_mut_ptr(),
                        ::core::mem::size_of::<[i8; 64]>() as u64,
                        b"%lld\0" as *const u8 as *const i8,
                        (*tv).tv_sec as i64,
                    )
                });
                (unsafe {
                    cb.expect("non-null function pointer")((*fte).key, s.as_mut_ptr(), arg)
                });
            } else {
                (unsafe {
                    cb.expect("non-null function pointer")((*fte).key, value as *const i8, arg)
                });
                (unsafe { free(value) });
            }
        }
        i = i.wrapping_add(1);
    }
    fe = format_entry_tree_RB_MINMAX(unsafe { &mut (*ft).tree }, -(1 as i32));
    while !fe.is_null() {
        if (unsafe { (*fe).time }) != 0 as i32 as i64 {
            (unsafe {
                xsnprintf(
                    s.as_mut_ptr(),
                    ::core::mem::size_of::<[i8; 64]>() as u64,
                    b"%lld\0" as *const u8 as *const i8,
                    (*fe).time as i64,
                )
            });
            (unsafe { cb.expect("non-null function pointer")((*fe).key, s.as_mut_ptr(), arg) });
        } else {
            if (unsafe { (*fe).value }).is_null() && (unsafe { ((*fe).cb).is_some() }) {
                (unsafe {
                    (*fe).value = ((*fe).cb).expect("non-null function pointer")(ft) as *mut i8
                });
                if (unsafe { (*fe).value }).is_null() {
                    (unsafe { (*fe).value = xstrdup(b"\0" as *const u8 as *const i8) });
                }
            }
            (unsafe { cb.expect("non-null function pointer")((*fe).key, (*fe).value, arg) });
        }
        fe = format_entry_tree_RB_NEXT(fe);
    }
}
#[no_mangle]
pub unsafe extern "C" fn format_add(
    mut ft: *mut format_tree,
    mut key: *const i8,
    mut fmt: *const i8,
    mut args: ...
) {
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut fe_now: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut ap: ::core::ffi::VaListImpl;
    fe = xmalloc(::core::mem::size_of::<format_entry>() as u64) as *mut format_entry;
    (*fe).key = xstrdup(key);
    fe_now = format_entry_tree_RB_INSERT(&mut (*ft).tree, fe);
    if !fe_now.is_null() {
        free((*fe).key as *mut libc::c_void);
        free(fe as *mut libc::c_void);
        free((*fe_now).value as *mut libc::c_void);
        fe = fe_now;
    }
    (*fe).cb = None;
    (*fe).time = 0 as i32 as time_t;
    ap = args.clone();
    xvasprintf(&mut (*fe).value, fmt, ap.as_va_list());
}
#[no_mangle]
pub extern "C" fn format_add_tv(
    mut ft: *mut format_tree,
    mut key: *const i8,
    mut tv: *mut timeval,
) {
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut fe_now: *mut format_entry = std::ptr::null_mut::<format_entry>();
    fe = (unsafe { xmalloc(::core::mem::size_of::<format_entry>() as u64) }) as *mut format_entry;
    (unsafe { (*fe).key = xstrdup(key) });
    fe_now = format_entry_tree_RB_INSERT(unsafe { &mut (*ft).tree }, fe);
    if !fe_now.is_null() {
        (unsafe { free((*fe).key as *mut libc::c_void) });
        (unsafe { free(fe as *mut libc::c_void) });
        (unsafe { free((*fe_now).value as *mut libc::c_void) });
        fe = fe_now;
    }
    (unsafe { (*fe).cb = None });
    (unsafe { (*fe).time = (*tv).tv_sec });
    (unsafe { (*fe).value = std::ptr::null_mut::<i8>() });
}
#[no_mangle]
pub extern "C" fn format_add_cb(mut ft: *mut format_tree, mut key: *const i8, mut cb: format_cb) {
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut fe_now: *mut format_entry = std::ptr::null_mut::<format_entry>();
    fe = (unsafe { xmalloc(::core::mem::size_of::<format_entry>() as u64) }) as *mut format_entry;
    (unsafe { (*fe).key = xstrdup(key) });
    fe_now = format_entry_tree_RB_INSERT(unsafe { &mut (*ft).tree }, fe);
    if !fe_now.is_null() {
        (unsafe { free((*fe).key as *mut libc::c_void) });
        (unsafe { free(fe as *mut libc::c_void) });
        (unsafe { free((*fe_now).value as *mut libc::c_void) });
        fe = fe_now;
    }
    (unsafe { (*fe).cb = cb });
    (unsafe { (*fe).time = 0 as i32 as time_t });
    (unsafe { (*fe).value = std::ptr::null_mut::<i8>() });
}
extern "C" fn format_quote_shell(mut s: *const i8) -> *mut i8 {
    let mut cp: *const i8 = std::ptr::null::<i8>();
    let mut out: *mut i8 = std::ptr::null_mut::<i8>();
    let mut at: *mut i8 = std::ptr::null_mut::<i8>();
    out = (unsafe {
        xmalloc(
            (strlen(s))
                .wrapping_mul(2 as i32 as u64)
                .wrapping_add(1 as i32 as u64),
        )
    }) as *mut i8;
    at = out;
    cp = s;
    while (unsafe { *cp }) as i32 != '\0' as i32 {
        if !(unsafe {
            strchr(
                b"|&;<>()$`\\\"'*?[# =%\0" as *const u8 as *const i8,
                *cp as i32,
            )
        })
        .is_null()
        {
            let fresh0 = at;
            at = unsafe { at.offset(1) };
            (unsafe { *fresh0 = '\\' as i32 as i8 });
        }
        let fresh1 = at;
        at = unsafe { at.offset(1) };
        (unsafe { *fresh1 = *cp });
        cp = unsafe { cp.offset(1) };
    }
    (unsafe { *at = '\0' as i32 as i8 });
    return out;
}
extern "C" fn format_quote_style(mut s: *const i8) -> *mut i8 {
    let mut cp: *const i8 = std::ptr::null::<i8>();
    let mut out: *mut i8 = std::ptr::null_mut::<i8>();
    let mut at: *mut i8 = std::ptr::null_mut::<i8>();
    out = (unsafe {
        xmalloc(
            (strlen(s))
                .wrapping_mul(2 as i32 as u64)
                .wrapping_add(1 as i32 as u64),
        )
    }) as *mut i8;
    at = out;
    cp = s;
    while (unsafe { *cp }) as i32 != '\0' as i32 {
        if (unsafe { *cp }) as i32 == '#' as i32 {
            let fresh2 = at;
            at = unsafe { at.offset(1) };
            (unsafe { *fresh2 = '#' as i32 as i8 });
        }
        let fresh3 = at;
        at = unsafe { at.offset(1) };
        (unsafe { *fresh3 = *cp });
        cp = unsafe { cp.offset(1) };
    }
    (unsafe { *at = '\0' as i32 as i8 });
    return out;
}
#[no_mangle]
pub extern "C" fn format_pretty_time(mut t: time_t, mut seconds: i32) -> *mut i8 {
    let mut now_tm: tm = tm {
        tm_sec: 0,
        tm_min: 0,
        tm_hour: 0,
        tm_mday: 0,
        tm_mon: 0,
        tm_year: 0,
        tm_wday: 0,
        tm_yday: 0,
        tm_isdst: 0,
        tm_gmtoff: 0,
        tm_zone: std::ptr::null::<i8>(),
    };
    let mut tm: tm = tm {
        tm_sec: 0,
        tm_min: 0,
        tm_hour: 0,
        tm_mday: 0,
        tm_mon: 0,
        tm_year: 0,
        tm_wday: 0,
        tm_yday: 0,
        tm_isdst: 0,
        tm_gmtoff: 0,
        tm_zone: std::ptr::null::<i8>(),
    };
    let mut now: time_t = 0;
    let mut age: time_t = 0;
    let mut s: [i8; 9] = [0; 9];
    (unsafe { time(&mut now) });
    if now < t {
        now = t;
    }
    age = now - t;
    (unsafe { localtime_r(&mut now, &mut now_tm) });
    (unsafe { localtime_r(&mut t, &mut tm) });
    if age < (24 as i32 * 3600 as i32) as i64 {
        if seconds != 0 {
            (unsafe {
                strftime(
                    s.as_mut_ptr(),
                    ::core::mem::size_of::<[i8; 9]>() as u64,
                    b"%H:%M:%S\0" as *const u8 as *const i8,
                    &mut tm,
                )
            });
        } else {
            (unsafe {
                strftime(
                    s.as_mut_ptr(),
                    ::core::mem::size_of::<[i8; 9]>() as u64,
                    b"%H:%M\0" as *const u8 as *const i8,
                    &mut tm,
                )
            });
        }
        return unsafe { xstrdup(s.as_mut_ptr()) };
    }
    if tm.tm_year == now_tm.tm_year && tm.tm_mon == now_tm.tm_mon
        || age < (28 as i32 * 24 as i32 * 3600 as i32) as i64
    {
        (unsafe {
            strftime(
                s.as_mut_ptr(),
                ::core::mem::size_of::<[i8; 9]>() as u64,
                b"%a%d\0" as *const u8 as *const i8,
                &mut tm,
            )
        });
        return unsafe { xstrdup(s.as_mut_ptr()) };
    }
    if tm.tm_year == now_tm.tm_year && tm.tm_mon < now_tm.tm_mon
        || tm.tm_year == now_tm.tm_year - 1 as i32 && tm.tm_mon > now_tm.tm_mon
    {
        (unsafe {
            strftime(
                s.as_mut_ptr(),
                ::core::mem::size_of::<[i8; 9]>() as u64,
                b"%d%b\0" as *const u8 as *const i8,
                &mut tm,
            )
        });
        return unsafe { xstrdup(s.as_mut_ptr()) };
    }
    (unsafe {
        strftime(
            s.as_mut_ptr(),
            ::core::mem::size_of::<[i8; 9]>() as u64,
            b"%h%y\0" as *const u8 as *const i8,
            &mut tm,
        )
    });
    return unsafe { xstrdup(s.as_mut_ptr()) };
}
extern "C" fn format_find(
    mut ft: *mut format_tree,
    mut key: *const i8,
    mut modifiers: i32,
    mut time_format: *const i8,
) -> *mut i8 {
    let mut current_block: u64;
    let mut fte: *mut format_table_entry = std::ptr::null_mut::<format_table_entry>();
    let mut value: *mut libc::c_void = std::ptr::null_mut::<libc::c_void>();
    let mut fe: *mut format_entry = std::ptr::null_mut::<format_entry>();
    let mut fe_find: format_entry = format_entry {
        key: std::ptr::null_mut::<i8>(),
        value: std::ptr::null_mut::<i8>(),
        time: 0,
        cb: None,
        entry: C2RustUnnamed_27 {
            rbe_left: std::ptr::null_mut::<format_entry>(),
            rbe_right: std::ptr::null_mut::<format_entry>(),
            rbe_parent: std::ptr::null_mut::<format_entry>(),
            rbe_color: 0,
        },
    };
    let mut envent: *mut environ_entry = std::ptr::null_mut::<environ_entry>();
    let mut o: *mut options_entry = std::ptr::null_mut::<options_entry>();
    let mut idx: i32 = 0;
    let mut found: *mut i8 = std::ptr::null_mut::<i8>();
    let mut saved: *mut i8 = std::ptr::null_mut::<i8>();
    let mut s: [i8; 512] = [0; 512];
    let mut errstr: *const i8 = std::ptr::null::<i8>();
    let mut t: time_t = 0 as i32 as time_t;
    let mut tm: tm = tm {
        tm_sec: 0,
        tm_min: 0,
        tm_hour: 0,
        tm_mday: 0,
        tm_mon: 0,
        tm_year: 0,
        tm_wday: 0,
        tm_yday: 0,
        tm_isdst: 0,
        tm_gmtoff: 0,
        tm_zone: std::ptr::null::<i8>(),
    };
    o = unsafe { options_parse_get(global_options, key, &mut idx, 0 as i32) };
    if o.is_null() && !(unsafe { (*ft).wp }).is_null() {
        o = unsafe { options_parse_get((*(*ft).wp).options, key, &mut idx, 0 as i32) };
    }
    if o.is_null() && !(unsafe { (*ft).w }).is_null() {
        o = unsafe { options_parse_get((*(*ft).w).options, key, &mut idx, 0 as i32) };
    }
    if o.is_null() {
        o = unsafe { options_parse_get(global_w_options, key, &mut idx, 0 as i32) };
    }
    if o.is_null() && !(unsafe { (*ft).s }).is_null() {
        o = unsafe { options_parse_get((*(*ft).s).options, key, &mut idx, 0 as i32) };
    }
    if o.is_null() {
        o = unsafe { options_parse_get(global_s_options, key, &mut idx, 0 as i32) };
    }
    if !o.is_null() {
        found = unsafe { options_to_string(o, idx, 1 as i32) };
    } else {
        fte = format_table_get(key);
        if !fte.is_null() {
            value = unsafe { ((*fte).cb).expect("non-null function pointer")(ft) };
            if (unsafe { (*fte).type_0 }) as u32 == FORMAT_TABLE_TIME as i32 as u32
                && !value.is_null()
            {
                t = unsafe { (*(value as *mut timeval)).tv_sec };
            } else {
                found = value as *mut i8;
            }
        } else {
            fe_find.key = key as *mut i8;
            fe = format_entry_tree_RB_FIND(unsafe { &mut (*ft).tree }, &mut fe_find);
            if !fe.is_null() {
                if (unsafe { (*fe).time }) != 0 as i32 as i64 {
                    t = unsafe { (*fe).time };
                } else {
                    if (unsafe { (*fe).value }).is_null() && (unsafe { ((*fe).cb).is_some() }) {
                        (unsafe {
                            (*fe).value =
                                ((*fe).cb).expect("non-null function pointer")(ft) as *mut i8
                        });
                        if (unsafe { (*fe).value }).is_null() {
                            (unsafe { (*fe).value = xstrdup(b"\0" as *const u8 as *const i8) });
                        }
                    }
                    found = unsafe { xstrdup((*fe).value) };
                }
            } else {
                if !modifiers & 0x1 as i32 != 0 {
                    envent = std::ptr::null_mut::<environ_entry>();
                    if !(unsafe { (*ft).s }).is_null() {
                        envent = unsafe { environ_find((*(*ft).s).environ, key) };
                    }
                    if envent.is_null() {
                        envent = unsafe { environ_find(global_environ, key) };
                    }
                    if !envent.is_null() && !(unsafe { (*envent).value }).is_null() {
                        found = unsafe { xstrdup((*envent).value) };
                        current_block = 13074811197591252876;
                    } else {
                        current_block = 17184638872671510253;
                    }
                } else {
                    current_block = 17184638872671510253;
                }
                match current_block {
                    13074811197591252876 => {}
                    _ => return std::ptr::null_mut::<i8>(),
                }
            }
        }
    }
    if modifiers & 0x1 as i32 != 0 {
        if t == 0 as i32 as i64 && !found.is_null() {
            t = (unsafe {
                strtonum(
                    found,
                    0 as i32 as i64,
                    9223372036854775807 as i64 as i64,
                    &mut errstr,
                )
            }) as time_t;
            if !errstr.is_null() {
                t = 0 as i32 as time_t;
            }
            (unsafe { free(found as *mut libc::c_void) });
        }
        if t == 0 as i32 as i64 {
            return std::ptr::null_mut::<i8>();
        }
        if modifiers & 0x400 as i32 != 0 {
            found = format_pretty_time(t, 0 as i32);
        } else {
            if !time_format.is_null() {
                (unsafe { localtime_r(&mut t, &mut tm) });
                (unsafe {
                    strftime(
                        s.as_mut_ptr(),
                        ::core::mem::size_of::<[i8; 512]>() as u64,
                        time_format,
                        &mut tm,
                    )
                });
            } else {
                (unsafe { ctime_r(&mut t, s.as_mut_ptr()) });
                s[(unsafe { strcspn(s.as_mut_ptr(), b"\n\0" as *const u8 as *const i8) })
                    as usize] = '\0' as i32 as i8;
            }
            found = unsafe { xstrdup(s.as_mut_ptr()) };
        }
        return found;
    }
    if t != 0 as i32 as i64 {
        (unsafe {
            xasprintf(
                &mut found as *mut *mut i8,
                b"%lld\0" as *const u8 as *const i8,
                t as i64,
            )
        });
    } else if found.is_null() {
        return std::ptr::null_mut::<i8>();
    }
    if modifiers & 0x2 as i32 != 0 {
        saved = found;
        found = unsafe { xstrdup(__xpg_basename(saved)) };
        (unsafe { free(saved as *mut libc::c_void) });
    }
    if modifiers & 0x4 as i32 != 0 {
        saved = found;
        found = unsafe { xstrdup(dirname(saved)) };
        (unsafe { free(saved as *mut libc::c_void) });
    }
    if modifiers & 0x8 as i32 != 0 {
        saved = found;
        found = format_quote_shell(saved);
        (unsafe { free(saved as *mut libc::c_void) });
    }
    if modifiers & 0x2000 as i32 != 0 {
        saved = found;
        found = format_quote_style(saved);
        (unsafe { free(saved as *mut libc::c_void) });
    }
    return found;
}
extern "C" fn format_unescape(mut s: *const i8) -> *mut i8 {
    let mut out: *mut i8 = std::ptr::null_mut::<i8>();
    let mut cp: *mut i8 = std::ptr::null_mut::<i8>();
    let mut brackets: i32 = 0 as i32;
    out = (unsafe { xmalloc((strlen(s)).wrapping_add(1 as i32 as u64)) }) as *mut i8;
    cp = out;
    while (unsafe { *s }) as i32 != '\0' as i32 {
        if (unsafe { *s }) as i32 == '#' as i32
            && (unsafe { *s.offset(1 as i32 as isize) }) as i32 == '{' as i32
        {
            brackets += 1;
        }
        if brackets == 0 as i32
            && (unsafe { *s }) as i32 == '#' as i32
            && !(unsafe {
                strchr(
                    b",#{}:\0" as *const u8 as *const i8,
                    *s.offset(1 as i32 as isize) as i32,
                )
            })
            .is_null()
        {
            s = unsafe { s.offset(1) };
            let fresh4 = cp;
            cp = unsafe { cp.offset(1) };
            (unsafe { *fresh4 = *s });
        } else {
            if (unsafe { *s }) as i32 == '}' as i32 {
                brackets -= 1;
            }
            let fresh5 = cp;
            cp = unsafe { cp.offset(1) };
            (unsafe { *fresh5 = *s });
        }
        s = unsafe { s.offset(1) };
    }
    (unsafe { *cp = '\0' as i32 as i8 });
    return out;
}
extern "C" fn format_strip(mut s: *const i8) -> *mut i8 {
    let mut out: *mut i8 = std::ptr::null_mut::<i8>();
    let mut cp: *mut i8 = std::ptr::null_mut::<i8>();
    let mut brackets: i32 = 0 as i32;
    out = (unsafe { xmalloc((strlen(s)).wrapping_add(1 as i32 as u64)) }) as *mut i8;
    cp = out;
    while (unsafe { *s }) as i32 != '\0' as i32 {
        if (unsafe { *s }) as i32 == '#' as i32
            && (unsafe { *s.offset(1 as i32 as isize) }) as i32 == '{' as i32
        {
            brackets += 1;
        }
        if (unsafe { *s }) as i32 == '#' as i32
            && !(unsafe {
                strchr(
                    b",#{}:\0" as *const u8 as *const i8,
                    *s.offset(1 as i32 as isize) as i32,
                )
            })
            .is_null()
        {
            if brackets != 0 as i32 {
                let fresh6 = cp;
                cp = unsafe { cp.offset(1) };
                (unsafe { *fresh6 = *s });
            }
        } else {
            if (unsafe { *s }) as i32 == '}' as i32 {
                brackets -= 1;
            }
            let fresh7 = cp;
            cp = unsafe { cp.offset(1) };
            (unsafe { *fresh7 = *s });
        }
        s = unsafe { s.offset(1) };
    }
    (unsafe { *cp = '\0' as i32 as i8 });
    return out;
}
#[no_mangle]
pub extern "C" fn format_skip(mut s: *const i8, mut end: *const i8) -> *const i8 {
    let mut brackets: i32 = 0 as i32;
    while (unsafe { *s }) as i32 != '\0' as i32 {
        if (unsafe { *s }) as i32 == '#' as i32
            && (unsafe { *s.offset(1 as i32 as isize) }) as i32 == '{' as i32
        {
            brackets += 1;
        }
        if (unsafe { *s }) as i32 == '#' as i32
            && (unsafe { *s.offset(1 as i32 as isize) }) as i32 != '\0' as i32
            && !(unsafe {
                strchr(
                    b",#{}:\0" as *const u8 as *const i8,
                    *s.offset(1 as i32 as isize) as i32,
                )
            })
            .is_null()
        {
            s = unsafe { s.offset(1) };
        } else {
            if (unsafe { *s }) as i32 == '}' as i32 {
                brackets -= 1;
            }
            if !(unsafe { strchr(end, *s as i32) }).is_null() && brackets == 0 as i32 {
                break;
            }
        }
        s = unsafe { s.offset(1) };
    }
    if (unsafe { *s }) as i32 == '\0' as i32 {
        return std::ptr::null::<i8>();
    }
    return s;
}
extern "C" fn format_choose(
    mut es: *mut format_expand_state,
    mut s: *const i8,
    mut left: *mut *mut i8,
    mut right: *mut *mut i8,
    mut expand: i32,
) -> i32 {
    let mut cp: *const i8 = std::ptr::null::<i8>();
    let mut left0: *mut i8 = std::ptr::null_mut::<i8>();
    let mut right0: *mut i8 = std::ptr::null_mut::<i8>();
    cp = format_skip(s, b",\0" as *const u8 as *const i8);
    if cp.is_null() {
        return -(1 as i32);
    }
    left0 = unsafe { xstrndup(s, cp.offset_from(s) as i64 as size_t) };
    right0 = unsafe { xstrdup(cp.offset(1 as i32 as isize)) };
    if expand != 0 {
        (unsafe { *left = format_expand1(es, left0) });
        (unsafe { free(left0 as *mut libc::c_void) });
        (unsafe { *right = format_expand1(es, right0) });
        (unsafe { free(right0 as *mut libc::c_void) });
    } else {
        (unsafe { *left = left0 });
        (unsafe { *right = right0 });
    }
    return 0 as i32;
}
#[no_mangle]
pub extern "C" fn format_true(mut s: *const i8) -> i32 {
    if !s.is_null()
        && (unsafe { *s }) as i32 != '\0' as i32
        && ((unsafe { *s.offset(0 as i32 as isize) }) as i32 != '0' as i32
            || (unsafe { *s.offset(1 as i32 as isize) }) as i32 != '\0' as i32)
    {
        return 1 as i32;
    }
    return 0 as i32;
}
extern "C" fn format_is_end(mut c: i8) -> i32 {
    return (c as i32 == ';' as i32 || c as i32 == ':' as i32) as i32;
}
extern "C" fn format_add_modifier(
    mut list: *mut *mut format_modifier,
    mut count: *mut u_int,
    mut c: *const i8,
    mut n: size_t,
    mut argv: *mut *mut i8,
    mut argc: i32,
) {
    let mut fm: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    (unsafe {
        *list = xreallocarray(
            *list as *mut libc::c_void,
            (*count).wrapping_add(1 as i32 as u32) as size_t,
            ::core::mem::size_of::<format_modifier>() as u64,
        ) as *mut format_modifier
    });
    let fresh8 = unsafe { *count };
    (unsafe { *count = (*count).wrapping_add(1) });
    fm = (unsafe { &mut *(*list).offset(fresh8 as isize) }) as *mut format_modifier;
    (unsafe {
        memcpy(
            ((*fm).modifier).as_mut_ptr() as *mut libc::c_void,
            c as *const libc::c_void,
            n,
        )
    });
    (unsafe { (*fm).modifier[n as usize] = '\0' as i32 as i8 });
    (unsafe { (*fm).size = n as u_int });
    (unsafe { (*fm).argv = argv });
    (unsafe { (*fm).argc = argc });
}
extern "C" fn format_free_modifiers(mut list: *mut format_modifier, mut count: u_int) {
    let mut i: u_int = 0;
    i = 0 as i32 as u_int;
    while i < count {
        (unsafe {
            cmd_free_argv(
                (*list.offset(i as isize)).argc,
                (*list.offset(i as isize)).argv,
            )
        });
        i = i.wrapping_add(1);
    }
    (unsafe { free(list as *mut libc::c_void) });
}
extern "C" fn format_build_modifiers(
    mut es: *mut format_expand_state,
    mut s: *mut *const i8,
    mut count: *mut u_int,
) -> *mut format_modifier {
    let mut cp: *const i8 = unsafe { *s };
    let mut end: *const i8 = std::ptr::null::<i8>();
    let mut list: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    let mut c: i8 = 0;
    let mut last: [i8; 4] =
        *(unsafe { ::core::mem::transmute::<&[u8; 4], &mut [i8; 4]>(b"X;:\0") });
    let mut argv: *mut *mut i8 = std::ptr::null_mut::<*mut i8>();
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    let mut argc: i32 = 0;
    (unsafe { *count = 0 as i32 as u_int });
    while (unsafe { *cp }) as i32 != '\0' as i32 && (unsafe { *cp }) as i32 != ':' as i32 {
        if (unsafe { *cp }) as i32 == ';' as i32 {
            cp = unsafe { cp.offset(1) };
        }
        if !(unsafe {
            strchr(
                b"labcdnwETSWPL<>\0" as *const u8 as *const i8,
                *cp.offset(0 as i32 as isize) as i32,
            )
        })
        .is_null()
            && format_is_end(unsafe { *cp.offset(1 as i32 as isize) }) != 0
        {
            format_add_modifier(
                &mut list,
                count,
                cp,
                1 as i32 as size_t,
                std::ptr::null_mut::<*mut i8>(),
                0 as i32,
            );
            cp = unsafe { cp.offset(1) };
        } else if ((unsafe {
            memcmp(
                b"||\0" as *const u8 as *const i8 as *const libc::c_void,
                cp as *const libc::c_void,
                2 as i32 as u64,
            )
        }) == 0 as i32
            || (unsafe {
                memcmp(
                    b"&&\0" as *const u8 as *const i8 as *const libc::c_void,
                    cp as *const libc::c_void,
                    2 as i32 as u64,
                )
            }) == 0 as i32
            || (unsafe {
                memcmp(
                    b"!=\0" as *const u8 as *const i8 as *const libc::c_void,
                    cp as *const libc::c_void,
                    2 as i32 as u64,
                )
            }) == 0 as i32
            || (unsafe {
                memcmp(
                    b"==\0" as *const u8 as *const i8 as *const libc::c_void,
                    cp as *const libc::c_void,
                    2 as i32 as u64,
                )
            }) == 0 as i32
            || (unsafe {
                memcmp(
                    b"<=\0" as *const u8 as *const i8 as *const libc::c_void,
                    cp as *const libc::c_void,
                    2 as i32 as u64,
                )
            }) == 0 as i32
            || (unsafe {
                memcmp(
                    b">=\0" as *const u8 as *const i8 as *const libc::c_void,
                    cp as *const libc::c_void,
                    2 as i32 as u64,
                )
            }) == 0 as i32)
            && format_is_end(unsafe { *cp.offset(2 as i32 as isize) }) != 0
        {
            format_add_modifier(
                &mut list,
                count,
                cp,
                2 as i32 as size_t,
                std::ptr::null_mut::<*mut i8>(),
                0 as i32,
            );
            cp = unsafe { cp.offset(2 as i32 as isize) };
        } else {
            if (unsafe {
                strchr(
                    b"mCNst=peq\0" as *const u8 as *const i8,
                    *cp.offset(0 as i32 as isize) as i32,
                )
            })
            .is_null()
            {
                break;
            }
            c = unsafe { *cp.offset(0 as i32 as isize) };
            if format_is_end(unsafe { *cp.offset(1 as i32 as isize) }) != 0 {
                format_add_modifier(
                    &mut list,
                    count,
                    cp,
                    1 as i32 as size_t,
                    std::ptr::null_mut::<*mut i8>(),
                    0 as i32,
                );
                cp = unsafe { cp.offset(1) };
            } else {
                argv = std::ptr::null_mut::<*mut i8>();
                argc = 0 as i32;
                if (unsafe {
                    *(*__ctype_b_loc())
                        .offset(*cp.offset(1 as i32 as isize) as u_char as i32 as isize)
                }) as i32
                    & _ISpunct as i32 as u16 as i32
                    == 0
                    || (unsafe { *cp.offset(1 as i32 as isize) }) as i32 == '-' as i32
                {
                    end = format_skip(
                        unsafe { cp.offset(1 as i32 as isize) },
                        b":;\0" as *const u8 as *const i8,
                    );
                    if end.is_null() {
                        break;
                    }
                    argv = (unsafe {
                        xcalloc(1 as i32 as size_t, ::core::mem::size_of::<*mut i8>() as u64)
                    }) as *mut *mut i8;
                    value = unsafe {
                        xstrndup(
                            cp.offset(1 as i32 as isize),
                            end.offset_from(cp.offset(1 as i32 as isize)) as i64 as size_t,
                        )
                    };
                    let fresh9 = unsafe { &mut (*argv.offset(0 as i32 as isize)) };
                    *fresh9 = format_expand1(es, value);
                    (unsafe { free(value as *mut libc::c_void) });
                    argc = 1 as i32;
                    format_add_modifier(&mut list, count, &mut c, 1 as i32 as size_t, argv, argc);
                    cp = end;
                } else {
                    last[0 as i32 as usize] = unsafe { *cp.offset(1 as i32 as isize) };
                    cp = unsafe { cp.offset(1) };
                    loop {
                        if (unsafe { *cp.offset(0 as i32 as isize) }) as i32
                            == last[0 as i32 as usize] as i32
                            && format_is_end(unsafe { *cp.offset(1 as i32 as isize) }) != 0
                        {
                            cp = unsafe { cp.offset(1) };
                            break;
                        } else {
                            end = format_skip(
                                unsafe { cp.offset(1 as i32 as isize) },
                                last.as_mut_ptr(),
                            );
                            if end.is_null() {
                                break;
                            }
                            cp = unsafe { cp.offset(1) };
                            argv = (unsafe {
                                xreallocarray(
                                    argv as *mut libc::c_void,
                                    (argc + 1 as i32) as size_t,
                                    ::core::mem::size_of::<*mut i8>() as u64,
                                )
                            }) as *mut *mut i8;
                            value = unsafe { xstrndup(cp, end.offset_from(cp) as i64 as size_t) };
                            let fresh10 = argc;
                            argc = argc + 1;
                            let fresh11 = unsafe { &mut (*argv.offset(fresh10 as isize)) };
                            *fresh11 = format_expand1(es, value);
                            (unsafe { free(value as *mut libc::c_void) });
                            cp = end;
                            if format_is_end(unsafe { *cp.offset(0 as i32 as isize) }) != 0 {
                                break;
                            }
                        }
                    }
                    format_add_modifier(&mut list, count, &mut c, 1 as i32 as size_t, argv, argc);
                }
            }
        }
    }
    if (unsafe { *cp }) as i32 != ':' as i32 {
        format_free_modifiers(list, unsafe { *count });
        (unsafe { *count = 0 as i32 as u_int });
        return std::ptr::null_mut::<format_modifier>();
    }
    (unsafe { *s = cp.offset(1 as i32 as isize) });
    return list;
}
extern "C" fn format_match(
    mut fm: *mut format_modifier,
    mut pattern: *const i8,
    mut text: *const i8,
) -> *mut i8 {
    let mut s: *const i8 = b"\0" as *const u8 as *const i8;
    let mut r: regex_t = regex_t {
        buffer: std::ptr::null_mut::<re_dfa_t>(),
        allocated: 0,
        used: 0,
        syntax: 0,
        fastmap: std::ptr::null_mut::<i8>(),
        translate: std::ptr::null_mut::<u8>(),
        re_nsub: 0,
        can_be_null_regs_allocated_fastmap_accurate_no_sub_not_bol_not_eol_newline_anchor: [0; 1],
        c2rust_padding: [0; 7],
    };
    let mut flags: i32 = 0 as i32;
    if (unsafe { (*fm).argc }) >= 1 as i32 {
        s = unsafe { *((*fm).argv).offset(0 as i32 as isize) };
    }
    if (unsafe { strchr(s, 'r' as i32) }).is_null() {
        if !(unsafe { strchr(s, 'i' as i32) }).is_null() {
            flags |= (1 as i32) << 4 as i32;
        }
        if (unsafe { fnmatch(pattern, text, flags) }) != 0 as i32 {
            return unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
        }
    } else {
        flags = 1 as i32 | (1 as i32) << 3 as i32;
        if !(unsafe { strchr(s, 'i' as i32) }).is_null() {
            flags |= (1 as i32) << 1 as i32;
        }
        if (unsafe { regcomp(&mut r, pattern, flags) }) != 0 as i32 {
            return unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
        }
        if (unsafe {
            regexec(
                &mut r,
                text,
                0 as i32 as size_t,
                std::ptr::null_mut::<regmatch_t>(),
                0 as i32,
            )
        }) != 0 as i32
        {
            (unsafe { regfree(&mut r) });
            return unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
        }
        (unsafe { regfree(&mut r) });
    }
    return unsafe { xstrdup(b"1\0" as *const u8 as *const i8) };
}
extern "C" fn format_sub(
    mut fm: *mut format_modifier,
    mut text: *const i8,
    mut pattern: *const i8,
    mut with: *const i8,
) -> *mut i8 {
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    let mut flags: i32 = 1 as i32;
    if (unsafe { (*fm).argc }) >= 3 as i32
        && !(unsafe { strchr(*((*fm).argv).offset(2 as i32 as isize), 'i' as i32) }).is_null()
    {
        flags |= (1 as i32) << 1 as i32;
    }
    value = unsafe { regsub(pattern, with, text, flags) };
    if value.is_null() {
        return unsafe { xstrdup(text) };
    }
    return value;
}
extern "C" fn format_search(
    mut fm: *mut format_modifier,
    mut wp: *mut window_pane,
    mut s: *const i8,
) -> *mut i8 {
    let mut ignore: i32 = 0 as i32;
    let mut regex: i32 = 0 as i32;
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    if (unsafe { (*fm).argc }) >= 1 as i32 {
        if !(unsafe { strchr(*((*fm).argv).offset(0 as i32 as isize), 'i' as i32) }).is_null() {
            ignore = 1 as i32;
        }
        if !(unsafe { strchr(*((*fm).argv).offset(0 as i32 as isize), 'r' as i32) }).is_null() {
            regex = 1 as i32;
        }
    }
    (unsafe {
        xasprintf(
            &mut value as *mut *mut i8,
            b"%u\0" as *const u8 as *const i8,
            window_pane_search(wp, s, regex, ignore),
        )
    });
    return value;
}
extern "C" fn format_session_name(mut es: *mut format_expand_state, mut fmt: *const i8) -> *mut i8 {
    let mut name: *mut i8 = std::ptr::null_mut::<i8>();
    let mut s: *mut session = std::ptr::null_mut::<session>();
    name = format_expand1(es, fmt);
    s = unsafe { sessions_RB_MINMAX(&mut sessions, -(1 as i32)) };
    while !s.is_null() {
        if (unsafe { strcmp((*s).name, name) }) == 0 as i32 {
            (unsafe { free(name as *mut libc::c_void) });
            return unsafe { xstrdup(b"1\0" as *const u8 as *const i8) };
        }
        s = unsafe { sessions_RB_NEXT(s) };
    }
    (unsafe { free(name as *mut libc::c_void) });
    return unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
}
extern "C" fn format_loop_sessions(
    mut es: *mut format_expand_state,
    mut fmt: *const i8,
) -> *mut i8 {
    let mut ft: *mut format_tree = unsafe { (*es).ft };
    let mut c: *mut client = unsafe { (*ft).client };
    let mut item: *mut cmdq_item = unsafe { (*ft).item };
    let mut nft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    let mut next: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<i8>(),
        },
        flags: 0,
    };
    let mut expanded: *mut i8 = std::ptr::null_mut::<i8>();
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    let mut valuelen: size_t = 0;
    let mut s: *mut session = std::ptr::null_mut::<session>();
    value = (unsafe { xcalloc(1 as i32 as size_t, 1 as i32 as size_t) }) as *mut i8;
    valuelen = 1 as i32 as size_t;
    s = unsafe { sessions_RB_MINMAX(&mut sessions, -(1 as i32)) };
    while !s.is_null() {
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 21], &[i8; 21]>(b"format_loop_sessions\0"))
                    .as_ptr(),
                b"session loop: $%u\0" as *const u8 as *const i8,
                (*s).id,
            )
        });
        nft = format_create(c, item, 0 as i32, unsafe { (*ft).flags });
        format_defaults(
            nft,
            unsafe { (*ft).c },
            s,
            std::ptr::null_mut::<winlink>(),
            std::ptr::null_mut::<window_pane>(),
        );
        format_copy_state(&mut next, es, 0 as i32);
        next.ft = nft;
        expanded = format_expand1(&mut next, fmt);
        format_free(next.ft);
        valuelen = (valuelen as u64).wrapping_add(unsafe { strlen(expanded) }) as size_t as size_t;
        value = (unsafe { xrealloc(value as *mut libc::c_void, valuelen) }) as *mut i8;
        (unsafe { strlcat(value, expanded, valuelen) });
        (unsafe { free(expanded as *mut libc::c_void) });
        s = unsafe { sessions_RB_NEXT(s) };
    }
    return value;
}
extern "C" fn format_window_name(mut es: *mut format_expand_state, mut fmt: *const i8) -> *mut i8 {
    let mut ft: *mut format_tree = unsafe { (*es).ft };
    let mut name: *mut i8 = std::ptr::null_mut::<i8>();
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    if (unsafe { (*ft).s }).is_null() {
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 19], &[i8; 19]>(b"format_window_name\0")).as_ptr(),
                b"window name but no session\0" as *const u8 as *const i8,
            )
        });
        return std::ptr::null_mut::<i8>();
    }
    name = format_expand1(es, fmt);
    wl = unsafe { winlinks_RB_MINMAX(&mut (*(*ft).s).windows, -(1 as i32)) };
    while !wl.is_null() {
        if (unsafe { strcmp((*(*wl).window).name, name) }) == 0 as i32 {
            (unsafe { free(name as *mut libc::c_void) });
            return unsafe { xstrdup(b"1\0" as *const u8 as *const i8) };
        }
        wl = unsafe { winlinks_RB_NEXT(wl) };
    }
    (unsafe { free(name as *mut libc::c_void) });
    return unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
}
extern "C" fn format_loop_windows(mut es: *mut format_expand_state, mut fmt: *const i8) -> *mut i8 {
    let mut ft: *mut format_tree = unsafe { (*es).ft };
    let mut c: *mut client = unsafe { (*ft).client };
    let mut item: *mut cmdq_item = unsafe { (*ft).item };
    let mut nft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    let mut next: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<i8>(),
        },
        flags: 0,
    };
    let mut all: *mut i8 = std::ptr::null_mut::<i8>();
    let mut active: *mut i8 = std::ptr::null_mut::<i8>();
    let mut use_0: *mut i8 = std::ptr::null_mut::<i8>();
    let mut expanded: *mut i8 = std::ptr::null_mut::<i8>();
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    let mut valuelen: size_t = 0;
    let mut wl: *mut winlink = std::ptr::null_mut::<winlink>();
    let mut w: *mut window = std::ptr::null_mut::<window>();
    if (unsafe { (*ft).s }).is_null() {
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 20], &[i8; 20]>(b"format_loop_windows\0"))
                    .as_ptr(),
                b"window loop but no session\0" as *const u8 as *const i8,
            )
        });
        return std::ptr::null_mut::<i8>();
    }
    if format_choose(es, fmt, &mut all, &mut active, 0 as i32) != 0 as i32 {
        all = unsafe { xstrdup(fmt) };
        active = std::ptr::null_mut::<i8>();
    }
    value = (unsafe { xcalloc(1 as i32 as size_t, 1 as i32 as size_t) }) as *mut i8;
    valuelen = 1 as i32 as size_t;
    wl = unsafe { winlinks_RB_MINMAX(&mut (*(*ft).s).windows, -(1 as i32)) };
    while !wl.is_null() {
        w = unsafe { (*wl).window };
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 20], &[i8; 20]>(b"format_loop_windows\0"))
                    .as_ptr(),
                b"window loop: %u @%u\0" as *const u8 as *const i8,
                (*wl).idx,
                (*w).id,
            )
        });
        if !active.is_null() && wl == (unsafe { (*(*ft).s).curw }) {
            use_0 = active;
        } else {
            use_0 = all;
        }
        nft = format_create(
            c,
            item,
            (0x40000000 as u32 | (unsafe { (*w).id })) as i32,
            unsafe { (*ft).flags },
        );
        format_defaults(
            nft,
            unsafe { (*ft).c },
            unsafe { (*ft).s },
            wl,
            std::ptr::null_mut::<window_pane>(),
        );
        format_copy_state(&mut next, es, 0 as i32);
        next.ft = nft;
        expanded = format_expand1(&mut next, use_0);
        format_free(nft);
        valuelen = (valuelen as u64).wrapping_add(unsafe { strlen(expanded) }) as size_t as size_t;
        value = (unsafe { xrealloc(value as *mut libc::c_void, valuelen) }) as *mut i8;
        (unsafe { strlcat(value, expanded, valuelen) });
        (unsafe { free(expanded as *mut libc::c_void) });
        wl = unsafe { winlinks_RB_NEXT(wl) };
    }
    (unsafe { free(active as *mut libc::c_void) });
    (unsafe { free(all as *mut libc::c_void) });
    return value;
}
extern "C" fn format_loop_panes(mut es: *mut format_expand_state, mut fmt: *const i8) -> *mut i8 {
    let mut ft: *mut format_tree = unsafe { (*es).ft };
    let mut c: *mut client = unsafe { (*ft).client };
    let mut item: *mut cmdq_item = unsafe { (*ft).item };
    let mut nft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    let mut next: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<i8>(),
        },
        flags: 0,
    };
    let mut all: *mut i8 = std::ptr::null_mut::<i8>();
    let mut active: *mut i8 = std::ptr::null_mut::<i8>();
    let mut use_0: *mut i8 = std::ptr::null_mut::<i8>();
    let mut expanded: *mut i8 = std::ptr::null_mut::<i8>();
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    let mut valuelen: size_t = 0;
    let mut wp: *mut window_pane = std::ptr::null_mut::<window_pane>();
    if (unsafe { (*ft).w }).is_null() {
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 18], &[i8; 18]>(b"format_loop_panes\0")).as_ptr(),
                b"pane loop but no window\0" as *const u8 as *const i8,
            )
        });
        return std::ptr::null_mut::<i8>();
    }
    if format_choose(es, fmt, &mut all, &mut active, 0 as i32) != 0 as i32 {
        all = unsafe { xstrdup(fmt) };
        active = std::ptr::null_mut::<i8>();
    }
    value = (unsafe { xcalloc(1 as i32 as size_t, 1 as i32 as size_t) }) as *mut i8;
    valuelen = 1 as i32 as size_t;
    wp = unsafe { (*(*ft).w).panes.tqh_first };
    while !wp.is_null() {
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 18], &[i8; 18]>(b"format_loop_panes\0")).as_ptr(),
                b"pane loop: %%%u\0" as *const u8 as *const i8,
                (*wp).id,
            )
        });
        if !active.is_null() && wp == (unsafe { (*(*ft).w).active }) {
            use_0 = active;
        } else {
            use_0 = all;
        }
        nft = format_create(
            c,
            item,
            (0x80000000 as u32 | (unsafe { (*wp).id })) as i32,
            unsafe { (*ft).flags },
        );
        format_defaults(
            nft,
            unsafe { (*ft).c },
            unsafe { (*ft).s },
            unsafe { (*ft).wl },
            wp,
        );
        format_copy_state(&mut next, es, 0 as i32);
        next.ft = nft;
        expanded = format_expand1(&mut next, use_0);
        format_free(nft);
        valuelen = (valuelen as u64).wrapping_add(unsafe { strlen(expanded) }) as size_t as size_t;
        value = (unsafe { xrealloc(value as *mut libc::c_void, valuelen) }) as *mut i8;
        (unsafe { strlcat(value, expanded, valuelen) });
        (unsafe { free(expanded as *mut libc::c_void) });
        wp = unsafe { (*wp).entry.tqe_next };
    }
    (unsafe { free(active as *mut libc::c_void) });
    (unsafe { free(all as *mut libc::c_void) });
    return value;
}
extern "C" fn format_loop_clients(mut es: *mut format_expand_state, mut fmt: *const i8) -> *mut i8 {
    let mut ft: *mut format_tree = unsafe { (*es).ft };
    let mut c: *mut client = std::ptr::null_mut::<client>();
    let mut item: *mut cmdq_item = unsafe { (*ft).item };
    let mut nft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    let mut next: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<i8>(),
        },
        flags: 0,
    };
    let mut expanded: *mut i8 = std::ptr::null_mut::<i8>();
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    let mut valuelen: size_t = 0;
    value = (unsafe { xcalloc(1 as i32 as size_t, 1 as i32 as size_t) }) as *mut i8;
    valuelen = 1 as i32 as size_t;
    c = unsafe { clients.tqh_first };
    while !c.is_null() {
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 20], &[i8; 20]>(b"format_loop_clients\0"))
                    .as_ptr(),
                b"client loop: %s\0" as *const u8 as *const i8,
                (*c).name,
            )
        });
        nft = format_create(c, item, 0 as i32, unsafe { (*ft).flags });
        format_defaults(nft, c, unsafe { (*ft).s }, unsafe { (*ft).wl }, unsafe {
            (*ft).wp
        });
        format_copy_state(&mut next, es, 0 as i32);
        next.ft = nft;
        expanded = format_expand1(&mut next, fmt);
        format_free(nft);
        valuelen = (valuelen as u64).wrapping_add(unsafe { strlen(expanded) }) as size_t as size_t;
        value = (unsafe { xrealloc(value as *mut libc::c_void, valuelen) }) as *mut i8;
        (unsafe { strlcat(value, expanded, valuelen) });
        (unsafe { free(expanded as *mut libc::c_void) });
        c = unsafe { (*c).entry.tqe_next };
    }
    return value;
}
extern "C" fn format_replace_expression(
    mut mexp: *mut format_modifier,
    mut es: *mut format_expand_state,
    mut copy: *const i8,
) -> *mut i8 {
    let mut current_block: u64;
    let mut argc: i32 = unsafe { (*mexp).argc };
    let mut errstr: *const i8 = std::ptr::null::<i8>();
    let mut endch: *mut i8 = std::ptr::null_mut::<i8>();
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    let mut left: *mut i8 = std::ptr::null_mut::<i8>();
    let mut right: *mut i8 = std::ptr::null_mut::<i8>();
    let mut use_fp: i32 = 0 as i32;
    let mut prec: u_int = 0 as i32 as u_int;
    let mut mleft: f64 = 0.;
    let mut mright: f64 = 0.;
    let mut result: f64 = 0.;
    let mut operator: C2RustUnnamed_40 = ADD;
    if (unsafe {
        strcmp(
            *((*mexp).argv).offset(0 as i32 as isize),
            b"+\0" as *const u8 as *const i8,
        )
    }) == 0 as i32
    {
        operator = ADD;
        current_block = 4495394744059808450;
    } else if (unsafe {
        strcmp(
            *((*mexp).argv).offset(0 as i32 as isize),
            b"-\0" as *const u8 as *const i8,
        )
    }) == 0 as i32
    {
        operator = SUBTRACT;
        current_block = 4495394744059808450;
    } else if (unsafe {
        strcmp(
            *((*mexp).argv).offset(0 as i32 as isize),
            b"*\0" as *const u8 as *const i8,
        )
    }) == 0 as i32
    {
        operator = MULTIPLY;
        current_block = 4495394744059808450;
    } else if (unsafe {
        strcmp(
            *((*mexp).argv).offset(0 as i32 as isize),
            b"/\0" as *const u8 as *const i8,
        )
    }) == 0 as i32
    {
        operator = DIVIDE;
        current_block = 4495394744059808450;
    } else if (unsafe {
        strcmp(
            *((*mexp).argv).offset(0 as i32 as isize),
            b"%\0" as *const u8 as *const i8,
        )
    }) == 0 as i32
        || (unsafe {
            strcmp(
                *((*mexp).argv).offset(0 as i32 as isize),
                b"m\0" as *const u8 as *const i8,
            )
        }) == 0 as i32
    {
        operator = MODULUS;
        current_block = 4495394744059808450;
    } else if (unsafe {
        strcmp(
            *((*mexp).argv).offset(0 as i32 as isize),
            b"==\0" as *const u8 as *const i8,
        )
    }) == 0 as i32
    {
        operator = EQUAL;
        current_block = 4495394744059808450;
    } else if (unsafe {
        strcmp(
            *((*mexp).argv).offset(0 as i32 as isize),
            b"!=\0" as *const u8 as *const i8,
        )
    }) == 0 as i32
    {
        operator = NOT_EQUAL;
        current_block = 4495394744059808450;
    } else if (unsafe {
        strcmp(
            *((*mexp).argv).offset(0 as i32 as isize),
            b">\0" as *const u8 as *const i8,
        )
    }) == 0 as i32
    {
        operator = GREATER_THAN;
        current_block = 4495394744059808450;
    } else if (unsafe {
        strcmp(
            *((*mexp).argv).offset(0 as i32 as isize),
            b"<\0" as *const u8 as *const i8,
        )
    }) == 0 as i32
    {
        operator = LESS_THAN;
        current_block = 4495394744059808450;
    } else if (unsafe {
        strcmp(
            *((*mexp).argv).offset(0 as i32 as isize),
            b">=\0" as *const u8 as *const i8,
        )
    }) == 0 as i32
    {
        operator = GREATER_THAN_EQUAL;
        current_block = 4495394744059808450;
    } else if (unsafe {
        strcmp(
            *((*mexp).argv).offset(0 as i32 as isize),
            b"<=\0" as *const u8 as *const i8,
        )
    }) == 0 as i32
    {
        operator = LESS_THAN_EQUAL;
        current_block = 4495394744059808450;
    } else {
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 26], &[i8; 26]>(b"format_replace_expression\0"))
                    .as_ptr(),
                b"expression has no valid operator: '%s'\0" as *const u8 as *const i8,
                *((*mexp).argv).offset(0 as i32 as isize),
            )
        });
        current_block = 2341159035123514568;
    }
    match current_block {
        4495394744059808450 => {
            if argc >= 2 as i32
                && !(unsafe { strchr(*((*mexp).argv).offset(1 as i32 as isize), 'f' as i32) })
                    .is_null()
            {
                use_fp = 1 as i32;
                prec = 2 as i32 as u_int;
            }
            if argc >= 3 as i32 {
                prec = (unsafe {
                    strtonum(
                        *((*mexp).argv).offset(2 as i32 as isize),
                        (-(2147483647 as i32) - 1 as i32) as i64,
                        2147483647 as i32 as i64,
                        &mut errstr,
                    )
                }) as u_int;
                if !errstr.is_null() {
                    (unsafe {
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 26], &[i8; 26]>(
                                b"format_replace_expression\0",
                            ))
                            .as_ptr(),
                            b"expression precision %s: %s\0" as *const u8 as *const i8,
                            errstr,
                            *((*mexp).argv).offset(2 as i32 as isize),
                        )
                    });
                    current_block = 2341159035123514568;
                } else {
                    current_block = 3437258052017859086;
                }
            } else {
                current_block = 3437258052017859086;
            }
            match current_block {
                2341159035123514568 => {}
                _ => {
                    if format_choose(es, copy, &mut left, &mut right, 1 as i32) != 0 as i32 {
                        (unsafe {
                            format_log1(
                                es,
                                (*::core::mem::transmute::<&[u8; 26], &[i8; 26]>(
                                    b"format_replace_expression\0",
                                ))
                                .as_ptr(),
                                b"expression syntax error\0" as *const u8 as *const i8,
                            )
                        });
                    } else {
                        mleft = unsafe { strtod(left, &mut endch) };
                        if (unsafe { *endch }) as i32 != '\0' as i32 {
                            (unsafe {
                                format_log1(
                                    es,
                                    (*::core::mem::transmute::<&[u8; 26], &[i8; 26]>(
                                        b"format_replace_expression\0",
                                    ))
                                    .as_ptr(),
                                    b"expression left side is invalid: %s\0" as *const u8
                                        as *const i8,
                                    left,
                                )
                            });
                        } else {
                            mright = unsafe { strtod(right, &mut endch) };
                            if (unsafe { *endch }) as i32 != '\0' as i32 {
                                (unsafe {
                                    format_log1(
                                        es,
                                        (*::core::mem::transmute::<&[u8; 26], &[i8; 26]>(
                                            b"format_replace_expression\0",
                                        ))
                                        .as_ptr(),
                                        b"expression right side is invalid: %s\0" as *const u8
                                            as *const i8,
                                        right,
                                    )
                                });
                            } else {
                                if use_fp == 0 {
                                    mleft = mleft as i64 as f64;
                                    mright = mright as i64 as f64;
                                }
                                (unsafe {
                                    format_log1(
                                        es,
                                        (*::core::mem::transmute::<&[u8; 26], &[i8; 26]>(
                                            b"format_replace_expression\0",
                                        ))
                                        .as_ptr(),
                                        b"expression left side is: %.*f\0" as *const u8
                                            as *const i8,
                                        prec,
                                        mleft,
                                    )
                                });
                                (unsafe {
                                    format_log1(
                                        es,
                                        (*::core::mem::transmute::<&[u8; 26], &[i8; 26]>(
                                            b"format_replace_expression\0",
                                        ))
                                        .as_ptr(),
                                        b"expression right side is: %.*f\0" as *const u8
                                            as *const i8,
                                        prec,
                                        mright,
                                    )
                                });
                                match operator as u32 {
                                    0 => {
                                        result = mleft + mright;
                                    }
                                    1 => {
                                        result = mleft - mright;
                                    }
                                    2 => {
                                        result = mleft * mright;
                                    }
                                    3 => {
                                        result = mleft / mright;
                                    }
                                    4 => {
                                        result = unsafe { fmod(mleft, mright) };
                                    }
                                    5 => {
                                        result = ((unsafe { fabs(mleft - mright) }) < 1e-9f64)
                                            as i32
                                            as f64;
                                    }
                                    6 => {
                                        result = ((unsafe { fabs(mleft - mright) }) > 1e-9f64)
                                            as i32
                                            as f64;
                                    }
                                    7 => {
                                        result = (mleft > mright) as i32 as f64;
                                    }
                                    8 => {
                                        result = (mleft >= mright) as i32 as f64;
                                    }
                                    9 => {
                                        result = (mleft < mright) as i32 as f64;
                                    }
                                    10 => {
                                        result = (mleft <= mright) as i32 as f64;
                                    }
                                    _ => {}
                                }
                                if use_fp != 0 {
                                    (unsafe {
                                        xasprintf(
                                            &mut value as *mut *mut i8,
                                            b"%.*f\0" as *const u8 as *const i8,
                                            prec,
                                            result,
                                        )
                                    });
                                } else {
                                    (unsafe {
                                        xasprintf(
                                            &mut value as *mut *mut i8,
                                            b"%.*f\0" as *const u8 as *const i8,
                                            prec,
                                            result as i64 as f64,
                                        )
                                    });
                                }
                                (unsafe {
                                    format_log1(
                                        es,
                                        (*::core::mem::transmute::<&[u8; 26], &[i8; 26]>(
                                            b"format_replace_expression\0",
                                        ))
                                        .as_ptr(),
                                        b"expression result is %s\0" as *const u8 as *const i8,
                                        value,
                                    )
                                });
                                (unsafe { free(right as *mut libc::c_void) });
                                (unsafe { free(left as *mut libc::c_void) });
                                return value;
                            }
                        }
                    }
                }
            }
        }
        _ => {}
    }
    (unsafe { free(right as *mut libc::c_void) });
    (unsafe { free(left as *mut libc::c_void) });
    return std::ptr::null_mut::<i8>();
}
extern "C" fn format_replace(
    mut es: *mut format_expand_state,
    mut key: *const i8,
    mut keylen: size_t,
    mut buf: *mut *mut i8,
    mut len: *mut size_t,
    mut off: *mut size_t,
) -> i32 {
    let mut current_block: u64;
    let mut ft: *mut format_tree = unsafe { (*es).ft };
    let mut wp: *mut window_pane = unsafe { (*ft).wp };
    let mut errstr: *const i8 = std::ptr::null::<i8>();
    let mut copy: *const i8 = std::ptr::null::<i8>();
    let mut cp: *const i8 = std::ptr::null::<i8>();
    let mut marker: *const i8 = std::ptr::null::<i8>();
    let mut time_format: *const i8 = std::ptr::null::<i8>();
    let mut copy0: *mut i8 = std::ptr::null_mut::<i8>();
    let mut condition: *mut i8 = std::ptr::null_mut::<i8>();
    let mut found: *mut i8 = std::ptr::null_mut::<i8>();
    let mut new: *mut i8 = std::ptr::null_mut::<i8>();
    let mut value: *mut i8 = std::ptr::null_mut::<i8>();
    let mut left: *mut i8 = std::ptr::null_mut::<i8>();
    let mut right: *mut i8 = std::ptr::null_mut::<i8>();
    let mut valuelen: size_t = 0;
    let mut modifiers: i32 = 0 as i32;
    let mut limit: i32 = 0 as i32;
    let mut width: i32 = 0 as i32;
    let mut j: i32 = 0;
    let mut c: i32 = 0;
    let mut list: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    let mut cmp: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    let mut search: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    let mut sub: *mut *mut format_modifier = std::ptr::null_mut::<*mut format_modifier>();
    let mut mexp: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    let mut fm: *mut format_modifier = std::ptr::null_mut::<format_modifier>();
    let mut i: u_int = 0;
    let mut count: u_int = 0;
    let mut nsub: u_int = 0 as i32 as u_int;
    let mut next: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<i8>(),
        },
        flags: 0,
    };
    copy0 = unsafe { xstrndup(key, keylen) };
    copy = copy0;
    list = format_build_modifiers(es, &mut copy, &mut count);
    i = 0 as i32 as u_int;
    while i < count {
        fm = (unsafe { &mut *list.offset(i as isize) }) as *mut format_modifier;
        if format_logging(ft) != 0 {
            (unsafe {
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0")).as_ptr(),
                    b"modifier %u is %s\0" as *const u8 as *const i8,
                    i,
                    ((*fm).modifier).as_mut_ptr(),
                )
            });
            j = 0 as i32;
            while j < (unsafe { (*fm).argc }) {
                (unsafe {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                            .as_ptr(),
                        b"modifier %u argument %d: %s\0" as *const u8 as *const i8,
                        i,
                        j,
                        *((*fm).argv).offset(j as isize),
                    )
                });
                j += 1;
            }
        }
        if (unsafe { (*fm).size }) == 1 as i32 as u32 {
            match (unsafe { (*fm).modifier[0 as i32 as usize] }) as i32 {
                109 | 60 | 62 => {
                    cmp = fm;
                }
                67 => {
                    search = fm;
                }
                115 => {
                    if (unsafe { (*fm).argc }) >= 2 as i32 {
                        sub = (unsafe {
                            xreallocarray(
                                sub as *mut libc::c_void,
                                nsub.wrapping_add(1 as i32 as u32) as size_t,
                                ::core::mem::size_of::<*mut format_modifier>() as u64,
                            )
                        }) as *mut *mut format_modifier;
                        let fresh12 = nsub;
                        nsub = nsub.wrapping_add(1);
                        let fresh13 = unsafe { &mut (*sub.offset(fresh12 as isize)) };
                        *fresh13 = fm;
                    }
                }
                61 => {
                    if (unsafe { (*fm).argc }) >= 1 as i32 {
                        limit = (unsafe {
                            strtonum(
                                *((*fm).argv).offset(0 as i32 as isize),
                                (-(2147483647 as i32) - 1 as i32) as i64,
                                2147483647 as i32 as i64,
                                &mut errstr,
                            )
                        }) as i32;
                        if !errstr.is_null() {
                            limit = 0 as i32;
                        }
                        if (unsafe { (*fm).argc }) >= 2 as i32
                            && !(unsafe { *((*fm).argv).offset(1 as i32 as isize) }).is_null()
                        {
                            marker = unsafe { *((*fm).argv).offset(1 as i32 as isize) };
                        }
                    }
                }
                112 => {
                    if (unsafe { (*fm).argc }) >= 1 as i32 {
                        width = (unsafe {
                            strtonum(
                                *((*fm).argv).offset(0 as i32 as isize),
                                (-(2147483647 as i32) - 1 as i32) as i64,
                                2147483647 as i32 as i64,
                                &mut errstr,
                            )
                        }) as i32;
                        if !errstr.is_null() {
                            width = 0 as i32;
                        }
                    }
                }
                119 => {
                    modifiers |= 0x1000 as i32;
                }
                101 => {
                    if !((unsafe { (*fm).argc }) < 1 as i32 || (unsafe { (*fm).argc }) > 3 as i32) {
                        mexp = fm;
                    }
                }
                108 => {
                    modifiers |= 0x10 as i32;
                }
                97 => {
                    modifiers |= 0x10000 as i32;
                }
                98 => {
                    modifiers |= 0x2 as i32;
                }
                99 => {
                    modifiers |= 0x20000 as i32;
                }
                100 => {
                    modifiers |= 0x4 as i32;
                }
                110 => {
                    modifiers |= 0x800 as i32;
                }
                116 => {
                    modifiers |= 0x1 as i32;
                    if (unsafe { (*fm).argc }) >= 1 as i32 {
                        if !(unsafe { strchr(*((*fm).argv).offset(0 as i32 as isize), 'p' as i32) })
                            .is_null()
                        {
                            modifiers |= 0x400 as i32;
                        } else if (unsafe { (*fm).argc }) >= 2 as i32
                            && !(unsafe {
                                strchr(*((*fm).argv).offset(0 as i32 as isize), 'f' as i32)
                            })
                            .is_null()
                        {
                            time_format =
                                format_strip(unsafe { *((*fm).argv).offset(1 as i32 as isize) });
                        }
                    }
                }
                113 => {
                    if (unsafe { (*fm).argc }) < 1 as i32 {
                        modifiers |= 0x8 as i32;
                    } else if !(unsafe {
                        strchr(*((*fm).argv).offset(0 as i32 as isize), 'e' as i32)
                    })
                    .is_null()
                        || !(unsafe { strchr(*((*fm).argv).offset(0 as i32 as isize), 'h' as i32) })
                            .is_null()
                    {
                        modifiers |= 0x2000 as i32;
                    }
                }
                69 => {
                    modifiers |= 0x20 as i32;
                }
                84 => {
                    modifiers |= 0x40 as i32;
                }
                78 => {
                    if (unsafe { (*fm).argc }) < 1 as i32
                        || !(unsafe { strchr(*((*fm).argv).offset(0 as i32 as isize), 'w' as i32) })
                            .is_null()
                    {
                        modifiers |= 0x4000 as i32;
                    } else if !(unsafe {
                        strchr(*((*fm).argv).offset(0 as i32 as isize), 's' as i32)
                    })
                    .is_null()
                    {
                        modifiers |= 0x8000 as i32;
                    }
                }
                83 => {
                    modifiers |= 0x80 as i32;
                }
                87 => {
                    modifiers |= 0x100 as i32;
                }
                80 => {
                    modifiers |= 0x200 as i32;
                }
                76 => {
                    modifiers |= 0x40000 as i32;
                }
                _ => {}
            }
        } else if (unsafe { (*fm).size }) == 2 as i32 as u32 {
            if (unsafe {
                strcmp(
                    ((*fm).modifier).as_mut_ptr(),
                    b"||\0" as *const u8 as *const i8,
                )
            }) == 0 as i32
                || (unsafe {
                    strcmp(
                        ((*fm).modifier).as_mut_ptr(),
                        b"&&\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                || (unsafe {
                    strcmp(
                        ((*fm).modifier).as_mut_ptr(),
                        b"==\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                || (unsafe {
                    strcmp(
                        ((*fm).modifier).as_mut_ptr(),
                        b"!=\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                || (unsafe {
                    strcmp(
                        ((*fm).modifier).as_mut_ptr(),
                        b">=\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                || (unsafe {
                    strcmp(
                        ((*fm).modifier).as_mut_ptr(),
                        b"<=\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
            {
                cmp = fm;
            }
        }
        i = i.wrapping_add(1);
    }
    if modifiers & 0x10 as i32 != 0 {
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0")).as_ptr(),
                b"literal string is '%s'\0" as *const u8 as *const i8,
                copy,
            )
        });
        value = format_unescape(copy);
    } else if modifiers & 0x10000 as i32 != 0 {
        new = format_expand1(es, copy);
        c = (unsafe { strtonum(new, 32 as i32 as i64, 126 as i32 as i64, &mut errstr) }) as i32;
        if !errstr.is_null() {
            value = unsafe { xstrdup(b"\0" as *const u8 as *const i8) };
        } else {
            (unsafe {
                xasprintf(
                    &mut value as *mut *mut i8,
                    b"%c\0" as *const u8 as *const i8,
                    c,
                )
            });
        }
        (unsafe { free(new as *mut libc::c_void) });
    } else if modifiers & 0x20000 as i32 != 0 {
        new = format_expand1(es, copy);
        c = unsafe { colour_fromstring(new) };
        if c == -(1 as i32) || {
            c = unsafe { colour_force_rgb(c) };
            c == -(1 as i32)
        } {
            value = unsafe { xstrdup(b"\0" as *const u8 as *const i8) };
        } else {
            (unsafe {
                xasprintf(
                    &mut value as *mut *mut i8,
                    b"%06x\0" as *const u8 as *const i8,
                    c & 0xffffff as i32,
                )
            });
        }
        (unsafe { free(new as *mut libc::c_void) });
    } else {
        if modifiers & 0x80 as i32 != 0 {
            value = format_loop_sessions(es, copy);
            if value.is_null() {
                current_block = 8654942318058171257;
            } else {
                current_block = 14584671873312672854;
            }
        } else if modifiers & 0x100 as i32 != 0 {
            value = format_loop_windows(es, copy);
            if value.is_null() {
                current_block = 8654942318058171257;
            } else {
                current_block = 14584671873312672854;
            }
        } else if modifiers & 0x200 as i32 != 0 {
            value = format_loop_panes(es, copy);
            if value.is_null() {
                current_block = 8654942318058171257;
            } else {
                current_block = 14584671873312672854;
            }
        } else if modifiers & 0x40000 as i32 != 0 {
            value = format_loop_clients(es, copy);
            if value.is_null() {
                current_block = 8654942318058171257;
            } else {
                current_block = 14584671873312672854;
            }
        } else if modifiers & 0x4000 as i32 != 0 {
            value = format_window_name(es, copy);
            if value.is_null() {
                current_block = 8654942318058171257;
            } else {
                current_block = 14584671873312672854;
            }
        } else if modifiers & 0x8000 as i32 != 0 {
            value = format_session_name(es, copy);
            if value.is_null() {
                current_block = 8654942318058171257;
            } else {
                current_block = 14584671873312672854;
            }
        } else if !search.is_null() {
            new = format_expand1(es, copy);
            if wp.is_null() {
                (unsafe {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                            .as_ptr(),
                        b"search '%s' but no pane\0" as *const u8 as *const i8,
                        new,
                    )
                });
                value = unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
            } else {
                (unsafe {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                            .as_ptr(),
                        b"search '%s' pane %%%u\0" as *const u8 as *const i8,
                        new,
                        (*wp).id,
                    )
                });
                value = format_search(search, wp, new);
            }
            (unsafe { free(new as *mut libc::c_void) });
            current_block = 14584671873312672854;
        } else if !cmp.is_null() {
            if format_choose(es, copy, &mut left, &mut right, 1 as i32) != 0 as i32 {
                (unsafe {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                            .as_ptr(),
                        b"compare %s syntax error: %s\0" as *const u8 as *const i8,
                        ((*cmp).modifier).as_mut_ptr(),
                        copy,
                    )
                });
                current_block = 8654942318058171257;
            } else {
                (unsafe {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                            .as_ptr(),
                        b"compare %s left is: %s\0" as *const u8 as *const i8,
                        ((*cmp).modifier).as_mut_ptr(),
                        left,
                    )
                });
                (unsafe {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                            .as_ptr(),
                        b"compare %s right is: %s\0" as *const u8 as *const i8,
                        ((*cmp).modifier).as_mut_ptr(),
                        right,
                    )
                });
                if (unsafe {
                    strcmp(
                        ((*cmp).modifier).as_mut_ptr(),
                        b"||\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                {
                    if format_true(left) != 0 || format_true(right) != 0 {
                        value = unsafe { xstrdup(b"1\0" as *const u8 as *const i8) };
                    } else {
                        value = unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
                    }
                } else if (unsafe {
                    strcmp(
                        ((*cmp).modifier).as_mut_ptr(),
                        b"&&\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                {
                    if format_true(left) != 0 && format_true(right) != 0 {
                        value = unsafe { xstrdup(b"1\0" as *const u8 as *const i8) };
                    } else {
                        value = unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
                    }
                } else if (unsafe {
                    strcmp(
                        ((*cmp).modifier).as_mut_ptr(),
                        b"==\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                {
                    if (unsafe { strcmp(left, right) }) == 0 as i32 {
                        value = unsafe { xstrdup(b"1\0" as *const u8 as *const i8) };
                    } else {
                        value = unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
                    }
                } else if (unsafe {
                    strcmp(
                        ((*cmp).modifier).as_mut_ptr(),
                        b"!=\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                {
                    if (unsafe { strcmp(left, right) }) != 0 as i32 {
                        value = unsafe { xstrdup(b"1\0" as *const u8 as *const i8) };
                    } else {
                        value = unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
                    }
                } else if (unsafe {
                    strcmp(
                        ((*cmp).modifier).as_mut_ptr(),
                        b"<\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                {
                    if (unsafe { strcmp(left, right) }) < 0 as i32 {
                        value = unsafe { xstrdup(b"1\0" as *const u8 as *const i8) };
                    } else {
                        value = unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
                    }
                } else if (unsafe {
                    strcmp(
                        ((*cmp).modifier).as_mut_ptr(),
                        b">\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                {
                    if (unsafe { strcmp(left, right) }) > 0 as i32 {
                        value = unsafe { xstrdup(b"1\0" as *const u8 as *const i8) };
                    } else {
                        value = unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
                    }
                } else if (unsafe {
                    strcmp(
                        ((*cmp).modifier).as_mut_ptr(),
                        b"<=\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                {
                    if (unsafe { strcmp(left, right) }) <= 0 as i32 {
                        value = unsafe { xstrdup(b"1\0" as *const u8 as *const i8) };
                    } else {
                        value = unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
                    }
                } else if (unsafe {
                    strcmp(
                        ((*cmp).modifier).as_mut_ptr(),
                        b">=\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                {
                    if (unsafe { strcmp(left, right) }) >= 0 as i32 {
                        value = unsafe { xstrdup(b"1\0" as *const u8 as *const i8) };
                    } else {
                        value = unsafe { xstrdup(b"0\0" as *const u8 as *const i8) };
                    }
                } else if (unsafe {
                    strcmp(
                        ((*cmp).modifier).as_mut_ptr(),
                        b"m\0" as *const u8 as *const i8,
                    )
                }) == 0 as i32
                {
                    value = format_match(cmp, left, right);
                }
                (unsafe { free(right as *mut libc::c_void) });
                (unsafe { free(left as *mut libc::c_void) });
                current_block = 14584671873312672854;
            }
        } else if (unsafe { *copy }) as i32 == '?' as i32 {
            cp = format_skip(
                unsafe { copy.offset(1 as i32 as isize) },
                b",\0" as *const u8 as *const i8,
            );
            if cp.is_null() {
                (unsafe {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                            .as_ptr(),
                        b"condition syntax error: %s\0" as *const u8 as *const i8,
                        copy.offset(1 as i32 as isize),
                    )
                });
                current_block = 8654942318058171257;
            } else {
                condition = unsafe {
                    xstrndup(
                        copy.offset(1 as i32 as isize),
                        cp.offset_from(copy.offset(1 as i32 as isize)) as i64 as size_t,
                    )
                };
                (unsafe {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                            .as_ptr(),
                        b"condition is: %s\0" as *const u8 as *const i8,
                        condition,
                    )
                });
                found = format_find(ft, condition, modifiers, time_format);
                if found.is_null() {
                    found = format_expand1(es, condition);
                    if (unsafe { strcmp(found, condition) }) == 0 as i32 {
                        (unsafe { free(found as *mut libc::c_void) });
                        found = unsafe { xstrdup(b"\0" as *const u8 as *const i8) };
                        (unsafe {
                            format_log1(
                                es,
                                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(
                                    b"format_replace\0",
                                ))
                                .as_ptr(),
                                b"condition '%s' not found; assuming false\0" as *const u8
                                    as *const i8,
                                condition,
                            )
                        });
                    }
                } else {
                    (unsafe {
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                                .as_ptr(),
                            b"condition '%s' found: %s\0" as *const u8 as *const i8,
                            condition,
                            found,
                        )
                    });
                }
                if format_choose(
                    es,
                    unsafe { cp.offset(1 as i32 as isize) },
                    &mut left,
                    &mut right,
                    0 as i32,
                ) != 0 as i32
                {
                    (unsafe {
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                                .as_ptr(),
                            b"condition '%s' syntax error: %s\0" as *const u8 as *const i8,
                            condition,
                            cp.offset(1 as i32 as isize),
                        )
                    });
                    (unsafe { free(found as *mut libc::c_void) });
                    current_block = 8654942318058171257;
                } else {
                    if format_true(found) != 0 {
                        (unsafe {
                            format_log1(
                                es,
                                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(
                                    b"format_replace\0",
                                ))
                                .as_ptr(),
                                b"condition '%s' is true\0" as *const u8 as *const i8,
                                condition,
                            )
                        });
                        value = format_expand1(es, left);
                    } else {
                        (unsafe {
                            format_log1(
                                es,
                                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(
                                    b"format_replace\0",
                                ))
                                .as_ptr(),
                                b"condition '%s' is false\0" as *const u8 as *const i8,
                                condition,
                            )
                        });
                        value = format_expand1(es, right);
                    }
                    (unsafe { free(right as *mut libc::c_void) });
                    (unsafe { free(left as *mut libc::c_void) });
                    (unsafe { free(condition as *mut libc::c_void) });
                    (unsafe { free(found as *mut libc::c_void) });
                    current_block = 14584671873312672854;
                }
            }
        } else {
            if !mexp.is_null() {
                value = format_replace_expression(mexp, es, copy);
                if value.is_null() {
                    value = unsafe { xstrdup(b"\0" as *const u8 as *const i8) };
                }
            } else if !(unsafe { strstr(copy, b"#{\0" as *const u8 as *const i8) }).is_null() {
                (unsafe {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                            .as_ptr(),
                        b"expanding inner format '%s'\0" as *const u8 as *const i8,
                        copy,
                    )
                });
                value = format_expand1(es, copy);
            } else {
                value = format_find(ft, copy, modifiers, time_format);
                if value.is_null() {
                    (unsafe {
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                                .as_ptr(),
                            b"format '%s' not found\0" as *const u8 as *const i8,
                            copy,
                        )
                    });
                    value = unsafe { xstrdup(b"\0" as *const u8 as *const i8) };
                } else {
                    (unsafe {
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                                .as_ptr(),
                            b"format '%s' found: %s\0" as *const u8 as *const i8,
                            copy,
                            value,
                        )
                    });
                }
            }
            current_block = 14584671873312672854;
        }
        match current_block {
            14584671873312672854 => {}
            _ => {
                (unsafe {
                    format_log1(
                        es,
                        (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0"))
                            .as_ptr(),
                        b"failed %s\0" as *const u8 as *const i8,
                        copy0,
                    )
                });
                (unsafe { free(sub as *mut libc::c_void) });
                format_free_modifiers(list, count);
                (unsafe { free(copy0 as *mut libc::c_void) });
                return -(1 as i32);
            }
        }
    }
    if modifiers & 0x20 as i32 != 0 {
        new = format_expand1(es, value);
        (unsafe { free(value as *mut libc::c_void) });
        value = new;
    } else if modifiers & 0x40 as i32 != 0 {
        format_copy_state(&mut next, es, 0x1 as i32);
        new = format_expand1(&mut next, value);
        (unsafe { free(value as *mut libc::c_void) });
        value = new;
    }
    i = 0 as i32 as u_int;
    while i < nsub {
        left = format_expand1(es, unsafe {
            *((**sub.offset(i as isize)).argv).offset(0 as i32 as isize)
        });
        right = format_expand1(es, unsafe {
            *((**sub.offset(i as isize)).argv).offset(1 as i32 as isize)
        });
        new = format_sub(unsafe { *sub.offset(i as isize) }, value, left, right);
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0")).as_ptr(),
                b"substitute '%s' to '%s': %s\0" as *const u8 as *const i8,
                left,
                right,
                new,
            )
        });
        (unsafe { free(value as *mut libc::c_void) });
        value = new;
        (unsafe { free(right as *mut libc::c_void) });
        (unsafe { free(left as *mut libc::c_void) });
        i = i.wrapping_add(1);
    }
    if limit > 0 as i32 {
        new = unsafe { format_trim_left(value, limit as u_int) };
        if !marker.is_null() && (unsafe { strcmp(new, value) }) != 0 as i32 {
            (unsafe { free(value as *mut libc::c_void) });
            (unsafe {
                xasprintf(
                    &mut value as *mut *mut i8,
                    b"%s%s\0" as *const u8 as *const i8,
                    new,
                    marker,
                )
            });
        } else {
            (unsafe { free(value as *mut libc::c_void) });
            value = new;
        }
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0")).as_ptr(),
                b"applied length limit %d: %s\0" as *const u8 as *const i8,
                limit,
                value,
            )
        });
    } else if limit < 0 as i32 {
        new = unsafe { format_trim_right(value, -limit as u_int) };
        if !marker.is_null() && (unsafe { strcmp(new, value) }) != 0 as i32 {
            (unsafe { free(value as *mut libc::c_void) });
            (unsafe {
                xasprintf(
                    &mut value as *mut *mut i8,
                    b"%s%s\0" as *const u8 as *const i8,
                    marker,
                    new,
                )
            });
        } else {
            (unsafe { free(value as *mut libc::c_void) });
            value = new;
        }
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0")).as_ptr(),
                b"applied length limit %d: %s\0" as *const u8 as *const i8,
                limit,
                value,
            )
        });
    }
    if width > 0 as i32 {
        new = unsafe { utf8_padcstr(value, width as u_int) };
        (unsafe { free(value as *mut libc::c_void) });
        value = new;
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0")).as_ptr(),
                b"applied padding width %d: %s\0" as *const u8 as *const i8,
                width,
                value,
            )
        });
    } else if width < 0 as i32 {
        new = unsafe { utf8_rpadcstr(value, -width as u_int) };
        (unsafe { free(value as *mut libc::c_void) });
        value = new;
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0")).as_ptr(),
                b"applied padding width %d: %s\0" as *const u8 as *const i8,
                width,
                value,
            )
        });
    }
    if modifiers & 0x800 as i32 != 0 {
        (unsafe {
            xasprintf(
                &mut new as *mut *mut i8,
                b"%zu\0" as *const u8 as *const i8,
                strlen(value),
            )
        });
        (unsafe { free(value as *mut libc::c_void) });
        value = new;
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0")).as_ptr(),
                b"replacing with length: %s\0" as *const u8 as *const i8,
                new,
            )
        });
    }
    if modifiers & 0x1000 as i32 != 0 {
        (unsafe {
            xasprintf(
                &mut new as *mut *mut i8,
                b"%u\0" as *const u8 as *const i8,
                format_width(value),
            )
        });
        (unsafe { free(value as *mut libc::c_void) });
        value = new;
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0")).as_ptr(),
                b"replacing with width: %s\0" as *const u8 as *const i8,
                new,
            )
        });
    }
    valuelen = unsafe { strlen(value) };
    while (unsafe { *len }).wrapping_sub(unsafe { *off }) < valuelen.wrapping_add(1 as i32 as u64) {
        (unsafe {
            *buf = xreallocarray(*buf as *mut libc::c_void, 2 as i32 as size_t, *len) as *mut i8
        });
        (unsafe { *len = (*len as u64).wrapping_mul(2 as i32 as u64) as size_t as size_t });
    }
    (unsafe {
        memcpy(
            (*buf).offset(*off as isize) as *mut libc::c_void,
            value as *const libc::c_void,
            valuelen,
        )
    });
    (unsafe { *off = (*off as u64).wrapping_add(valuelen) as size_t as size_t });
    (unsafe {
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_replace\0")).as_ptr(),
            b"replaced '%s' with '%s'\0" as *const u8 as *const i8,
            copy0,
            value,
        )
    });
    (unsafe { free(value as *mut libc::c_void) });
    (unsafe { free(sub as *mut libc::c_void) });
    format_free_modifiers(list, count);
    (unsafe { free(copy0 as *mut libc::c_void) });
    return 0 as i32;
}
extern "C" fn format_expand1(mut es: *mut format_expand_state, mut fmt: *const i8) -> *mut i8 {
    let mut ft: *mut format_tree = unsafe { (*es).ft };
    let mut buf: *mut i8 = std::ptr::null_mut::<i8>();
    let mut out: *mut i8 = std::ptr::null_mut::<i8>();
    let mut name: *mut i8 = std::ptr::null_mut::<i8>();
    let mut ptr: *const i8 = std::ptr::null::<i8>();
    let mut s: *const i8 = std::ptr::null::<i8>();
    let mut style_end: *const i8 = std::ptr::null::<i8>();
    let mut off: size_t = 0;
    let mut len: size_t = 0;
    let mut n: size_t = 0;
    let mut outlen: size_t = 0;
    let mut ch: i32 = 0;
    let mut brackets: i32 = 0;
    let mut expanded: [i8; 8192] = [0; 8192];
    if fmt.is_null() || (unsafe { *fmt }) as i32 == '\0' as i32 {
        return unsafe { xstrdup(b"\0" as *const u8 as *const i8) };
    }
    if (unsafe { (*es).loop_0 }) == 100 as i32 as u32 {
        (unsafe {
            format_log1(
                es,
                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_expand1\0")).as_ptr(),
                b"reached loop limit (%u)\0" as *const u8 as *const i8,
                100 as i32,
            )
        });
        return unsafe { xstrdup(b"\0" as *const u8 as *const i8) };
    }
    (unsafe { (*es).loop_0 = ((*es).loop_0).wrapping_add(1) });
    (unsafe {
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_expand1\0")).as_ptr(),
            b"expanding format: %s\0" as *const u8 as *const i8,
            fmt,
        )
    });
    if (unsafe { (*es).flags }) & 0x1 as i32 != 0 && !(unsafe { strchr(fmt, '%' as i32) }).is_null()
    {
        if (unsafe { (*es).time }) == 0 as i32 as i64 {
            (unsafe { (*es).time = time(std::ptr::null_mut::<time_t>()) });
            (unsafe { localtime_r(&mut (*es).time, &mut (*es).tm) });
        }
        if (unsafe {
            strftime(
                expanded.as_mut_ptr(),
                ::core::mem::size_of::<[i8; 8192]>() as u64,
                fmt,
                &mut (*es).tm,
            )
        }) == 0 as i32 as u64
        {
            (unsafe {
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_expand1\0")).as_ptr(),
                    b"format is too long\0" as *const u8 as *const i8,
                )
            });
            return unsafe { xstrdup(b"\0" as *const u8 as *const i8) };
        }
        if format_logging(ft) != 0 && (unsafe { strcmp(expanded.as_mut_ptr(), fmt) }) != 0 as i32 {
            (unsafe {
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_expand1\0")).as_ptr(),
                    b"after time expanded: %s\0" as *const u8 as *const i8,
                    expanded.as_mut_ptr(),
                )
            });
        }
        fmt = expanded.as_mut_ptr();
    }
    len = 64 as i32 as size_t;
    buf = (unsafe { xmalloc(len) }) as *mut i8;
    off = 0 as i32 as size_t;
    while (unsafe { *fmt }) as i32 != '\0' as i32 {
        if (unsafe { *fmt }) as i32 != '#' as i32 {
            while len.wrapping_sub(off) < 2 as i32 as u64 {
                buf = (unsafe { xreallocarray(buf as *mut libc::c_void, 2 as i32 as size_t, len) })
                    as *mut i8;
                len = (len as u64).wrapping_mul(2 as i32 as u64) as size_t as size_t;
            }
            let fresh14 = fmt;
            fmt = unsafe { fmt.offset(1) };
            let fresh15 = off;
            off = off.wrapping_add(1);
            (unsafe { *buf.offset(fresh15 as isize) = *fresh14 });
        } else {
            fmt = unsafe { fmt.offset(1) };
            let fresh16 = fmt;
            fmt = unsafe { fmt.offset(1) };
            ch = (unsafe { *fresh16 }) as u_char as i32;
            match ch {
                40 => {
                    brackets = 1 as i32;
                    ptr = fmt;
                    while (unsafe { *ptr }) as i32 != '\0' as i32 {
                        if (unsafe { *ptr }) as i32 == '(' as i32 {
                            brackets += 1;
                        }
                        if (unsafe { *ptr }) as i32 == ')' as i32 && {
                            brackets -= 1;
                            brackets == 0 as i32
                        } {
                            break;
                        }
                        ptr = unsafe { ptr.offset(1) };
                    }
                    if (unsafe { *ptr }) as i32 != ')' as i32 || brackets != 0 as i32 {
                        break;
                    }
                    n = (unsafe { ptr.offset_from(fmt) }) as i64 as size_t;
                    name = unsafe { xstrndup(fmt, n) };
                    (unsafe {
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_expand1\0"))
                                .as_ptr(),
                            b"found #(): %s\0" as *const u8 as *const i8,
                            name,
                        )
                    });
                    if (unsafe { (*ft).flags }) & 0x4 as i32 != 0
                        || (unsafe { (*es).flags }) & 0x2 as i32 != 0
                    {
                        out = unsafe { xstrdup(b"\0" as *const u8 as *const i8) };
                        (unsafe {
                            format_log1(
                                es,
                                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(
                                    b"format_expand1\0",
                                ))
                                .as_ptr(),
                                b"#() is disabled\0" as *const u8 as *const i8,
                            )
                        });
                    } else {
                        out = format_job_get(es, name);
                        (unsafe {
                            format_log1(
                                es,
                                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(
                                    b"format_expand1\0",
                                ))
                                .as_ptr(),
                                b"#() result: %s\0" as *const u8 as *const i8,
                                out,
                            )
                        });
                    }
                    (unsafe { free(name as *mut libc::c_void) });
                    outlen = unsafe { strlen(out) };
                    while len.wrapping_sub(off) < outlen.wrapping_add(1 as i32 as u64) {
                        buf = (unsafe {
                            xreallocarray(buf as *mut libc::c_void, 2 as i32 as size_t, len)
                        }) as *mut i8;
                        len = (len as u64).wrapping_mul(2 as i32 as u64) as size_t as size_t;
                    }
                    (unsafe {
                        memcpy(
                            buf.offset(off as isize) as *mut libc::c_void,
                            out as *const libc::c_void,
                            outlen,
                        )
                    });
                    off = (off as u64).wrapping_add(outlen) as size_t as size_t;
                    (unsafe { free(out as *mut libc::c_void) });
                    fmt = unsafe { fmt.offset(n.wrapping_add(1 as i32 as u64) as isize) };
                    continue;
                }
                123 => {
                    ptr = format_skip(
                        unsafe { (fmt as *mut i8).offset(-(2 as i32 as isize)) },
                        b"}\0" as *const u8 as *const i8,
                    );
                    if ptr.is_null() {
                        break;
                    }
                    n = (unsafe { ptr.offset_from(fmt) }) as i64 as size_t;
                    (unsafe {
                        format_log1(
                            es,
                            (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_expand1\0"))
                                .as_ptr(),
                            b"found #{}: %.*s\0" as *const u8 as *const i8,
                            n as i32,
                            fmt,
                        )
                    });
                    if format_replace(es, fmt, n, &mut buf, &mut len, &mut off) != 0 as i32 {
                        break;
                    }
                    fmt = unsafe { fmt.offset(n.wrapping_add(1 as i32 as u64) as isize) };
                    continue;
                }
                91 | 35 => {
                    ptr = unsafe { fmt.offset(-((ch == '[' as i32) as i32 as isize)) };
                    n = (2 as i32 - (ch == '[' as i32) as i32) as size_t;
                    while (unsafe { *ptr }) as i32 == '#' as i32 {
                        ptr = unsafe { ptr.offset(1) };
                        n = n.wrapping_add(1);
                    }
                    if (unsafe { *ptr }) as i32 == '[' as i32 {
                        style_end = format_skip(
                            unsafe { fmt.offset(-(2 as i32 as isize)) },
                            b"]\0" as *const u8 as *const i8,
                        );
                        (unsafe {
                            format_log1(
                                es,
                                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(
                                    b"format_expand1\0",
                                ))
                                .as_ptr(),
                                b"found #*%zu[\0" as *const u8 as *const i8,
                                n,
                            )
                        });
                        while len.wrapping_sub(off) < n.wrapping_add(2 as i32 as u64) {
                            buf = (unsafe {
                                xreallocarray(buf as *mut libc::c_void, 2 as i32 as size_t, len)
                            }) as *mut i8;
                            len = (len as u64).wrapping_mul(2 as i32 as u64) as size_t as size_t;
                        }
                        (unsafe {
                            memcpy(
                                buf.offset(off as isize) as *mut libc::c_void,
                                fmt.offset(-(2 as i32 as isize)) as *const libc::c_void,
                                n.wrapping_add(1 as i32 as u64),
                            )
                        });
                        off = (off as u64).wrapping_add(n.wrapping_add(1 as i32 as u64)) as size_t
                            as size_t;
                        fmt = unsafe { ptr.offset(1 as i32 as isize) };
                        continue;
                    }
                }
                125 | 44 => {}
                _ => {
                    s = std::ptr::null::<i8>();
                    if fmt > style_end {
                        if ch >= 'A' as i32 && ch <= 'Z' as i32 {
                            s = unsafe { format_upper[(ch - 'A' as i32) as usize] };
                        } else if ch >= 'a' as i32 && ch <= 'z' as i32 {
                            s = unsafe { format_lower[(ch - 'a' as i32) as usize] };
                        }
                    }
                    if s.is_null() {
                        while len.wrapping_sub(off) < 3 as i32 as u64 {
                            buf = (unsafe {
                                xreallocarray(buf as *mut libc::c_void, 2 as i32 as size_t, len)
                            }) as *mut i8;
                            len = (len as u64).wrapping_mul(2 as i32 as u64) as size_t as size_t;
                        }
                        let fresh18 = off;
                        off = off.wrapping_add(1);
                        (unsafe { *buf.offset(fresh18 as isize) = '#' as i32 as i8 });
                        let fresh19 = off;
                        off = off.wrapping_add(1);
                        (unsafe { *buf.offset(fresh19 as isize) = ch as i8 });
                        continue;
                    } else {
                        n = unsafe { strlen(s) };
                        (unsafe {
                            format_log1(
                                es,
                                (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(
                                    b"format_expand1\0",
                                ))
                                .as_ptr(),
                                b"found #%c: %s\0" as *const u8 as *const i8,
                                ch,
                                s,
                            )
                        });
                        if format_replace(es, s, n, &mut buf, &mut len, &mut off) != 0 as i32 {
                            break;
                        } else {
                            continue;
                        }
                    }
                }
            }
            (unsafe {
                format_log1(
                    es,
                    (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_expand1\0")).as_ptr(),
                    b"found #%c\0" as *const u8 as *const i8,
                    ch,
                )
            });
            while len.wrapping_sub(off) < 2 as i32 as u64 {
                buf = (unsafe { xreallocarray(buf as *mut libc::c_void, 2 as i32 as size_t, len) })
                    as *mut i8;
                len = (len as u64).wrapping_mul(2 as i32 as u64) as size_t as size_t;
            }
            let fresh17 = off;
            off = off.wrapping_add(1);
            (unsafe { *buf.offset(fresh17 as isize) = ch as i8 });
        }
    }
    (unsafe { *buf.offset(off as isize) = '\0' as i32 as i8 });
    (unsafe {
        format_log1(
            es,
            (*::core::mem::transmute::<&[u8; 15], &[i8; 15]>(b"format_expand1\0")).as_ptr(),
            b"result is: %s\0" as *const u8 as *const i8,
            buf,
        )
    });
    (unsafe { (*es).loop_0 = ((*es).loop_0).wrapping_sub(1) });
    return buf;
}
#[no_mangle]
pub extern "C" fn format_expand_time(mut ft: *mut format_tree, mut fmt: *const i8) -> *mut i8 {
    let mut es: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<i8>(),
        },
        flags: 0,
    };
    (unsafe {
        memset(
            &mut es as *mut format_expand_state as *mut libc::c_void,
            0 as i32,
            ::core::mem::size_of::<format_expand_state>() as u64,
        )
    });
    es.ft = ft;
    es.flags = 0x1 as i32;
    return format_expand1(&mut es, fmt);
}
#[no_mangle]
pub extern "C" fn format_expand(mut ft: *mut format_tree, mut fmt: *const i8) -> *mut i8 {
    let mut es: format_expand_state = format_expand_state {
        ft: std::ptr::null_mut::<format_tree>(),
        loop_0: 0,
        time: 0,
        tm: tm {
            tm_sec: 0,
            tm_min: 0,
            tm_hour: 0,
            tm_mday: 0,
            tm_mon: 0,
            tm_year: 0,
            tm_wday: 0,
            tm_yday: 0,
            tm_isdst: 0,
            tm_gmtoff: 0,
            tm_zone: std::ptr::null::<i8>(),
        },
        flags: 0,
    };
    (unsafe {
        memset(
            &mut es as *mut format_expand_state as *mut libc::c_void,
            0 as i32,
            ::core::mem::size_of::<format_expand_state>() as u64,
        )
    });
    es.ft = ft;
    es.flags = 0 as i32;
    return format_expand1(&mut es, fmt);
}
#[no_mangle]
pub extern "C" fn format_single(
    mut item: *mut cmdq_item,
    mut fmt: *const i8,
    mut c: *mut client,
    mut s: *mut session,
    mut wl: *mut winlink,
    mut wp: *mut window_pane,
) -> *mut i8 {
    let mut ft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    let mut expanded: *mut i8 = std::ptr::null_mut::<i8>();
    ft = format_create_defaults(item, c, s, wl, wp);
    expanded = format_expand(ft, fmt);
    format_free(ft);
    return expanded;
}
#[no_mangle]
pub extern "C" fn format_single_from_state(
    mut item: *mut cmdq_item,
    mut fmt: *const i8,
    mut c: *mut client,
    mut fs: *mut cmd_find_state,
) -> *mut i8 {
    return format_single(
        item,
        fmt,
        c,
        unsafe { (*fs).s },
        unsafe { (*fs).wl },
        unsafe { (*fs).wp },
    );
}
#[no_mangle]
pub extern "C" fn format_single_from_target(
    mut item: *mut cmdq_item,
    mut fmt: *const i8,
) -> *mut i8 {
    let mut tc: *mut client = unsafe { cmdq_get_target_client(item) };
    return format_single_from_state(item, fmt, tc, unsafe { cmdq_get_target(item) });
}
#[no_mangle]
pub extern "C" fn format_create_defaults(
    mut item: *mut cmdq_item,
    mut c: *mut client,
    mut s: *mut session,
    mut wl: *mut winlink,
    mut wp: *mut window_pane,
) -> *mut format_tree {
    let mut ft: *mut format_tree = std::ptr::null_mut::<format_tree>();
    if !item.is_null() {
        ft = format_create(unsafe { cmdq_get_client(item) }, item, 0 as i32, 0 as i32);
    } else {
        ft = format_create(std::ptr::null_mut::<client>(), item, 0 as i32, 0 as i32);
    }
    format_defaults(ft, c, s, wl, wp);
    return ft;
}
#[no_mangle]
pub extern "C" fn format_create_from_state(
    mut item: *mut cmdq_item,
    mut c: *mut client,
    mut fs: *mut cmd_find_state,
) -> *mut format_tree {
    return format_create_defaults(item, c, unsafe { (*fs).s }, unsafe { (*fs).wl }, unsafe {
        (*fs).wp
    });
}
#[no_mangle]
pub extern "C" fn format_create_from_target(mut item: *mut cmdq_item) -> *mut format_tree {
    let mut tc: *mut client = unsafe { cmdq_get_target_client(item) };
    return format_create_from_state(item, tc, unsafe { cmdq_get_target(item) });
}
#[no_mangle]
pub extern "C" fn format_defaults(
    mut ft: *mut format_tree,
    mut c: *mut client,
    mut s: *mut session,
    mut wl: *mut winlink,
    mut wp: *mut window_pane,
) {
    let mut pb: *mut paste_buffer = std::ptr::null_mut::<paste_buffer>();
    if !c.is_null() && !(unsafe { (*c).name }).is_null() {
        (unsafe {
            log_debug(
                b"%s: c=%s\0" as *const u8 as *const i8,
                (*::core::mem::transmute::<&[u8; 16], &[i8; 16]>(b"format_defaults\0")).as_ptr(),
                (*c).name,
            )
        });
    } else {
        (unsafe {
            log_debug(
                b"%s: c=none\0" as *const u8 as *const i8,
                (*::core::mem::transmute::<&[u8; 16], &[i8; 16]>(b"format_defaults\0")).as_ptr(),
            )
        });
    }
    if !s.is_null() {
        (unsafe {
            log_debug(
                b"%s: s=$%u\0" as *const u8 as *const i8,
                (*::core::mem::transmute::<&[u8; 16], &[i8; 16]>(b"format_defaults\0")).as_ptr(),
                (*s).id,
            )
        });
    } else {
        (unsafe {
            log_debug(
                b"%s: s=none\0" as *const u8 as *const i8,
                (*::core::mem::transmute::<&[u8; 16], &[i8; 16]>(b"format_defaults\0")).as_ptr(),
            )
        });
    }
    if !wl.is_null() {
        (unsafe {
            log_debug(
                b"%s: wl=%u\0" as *const u8 as *const i8,
                (*::core::mem::transmute::<&[u8; 16], &[i8; 16]>(b"format_defaults\0")).as_ptr(),
                (*wl).idx,
            )
        });
    } else {
        (unsafe {
            log_debug(
                b"%s: wl=none\0" as *const u8 as *const i8,
                (*::core::mem::transmute::<&[u8; 16], &[i8; 16]>(b"format_defaults\0")).as_ptr(),
            )
        });
    }
    if !wp.is_null() {
        (unsafe {
            log_debug(
                b"%s: wp=%%%u\0" as *const u8 as *const i8,
                (*::core::mem::transmute::<&[u8; 16], &[i8; 16]>(b"format_defaults\0")).as_ptr(),
                (*wp).id,
            )
        });
    } else {
        (unsafe {
            log_debug(
                b"%s: wp=none\0" as *const u8 as *const i8,
                (*::core::mem::transmute::<&[u8; 16], &[i8; 16]>(b"format_defaults\0")).as_ptr(),
            )
        });
    }
    if !c.is_null() && !s.is_null() && (unsafe { (*c).session }) != s {
        (unsafe {
            log_debug(
                b"%s: session does not match\0" as *const u8 as *const i8,
                (*::core::mem::transmute::<&[u8; 16], &[i8; 16]>(b"format_defaults\0")).as_ptr(),
            )
        });
    }
    if !wp.is_null() {
        (unsafe { (*ft).type_0 = FORMAT_TYPE_PANE });
    } else if !wl.is_null() {
        (unsafe { (*ft).type_0 = FORMAT_TYPE_WINDOW });
    } else if !s.is_null() {
        (unsafe { (*ft).type_0 = FORMAT_TYPE_SESSION });
    } else {
        (unsafe { (*ft).type_0 = FORMAT_TYPE_UNKNOWN });
    }
    if s.is_null() && !c.is_null() {
        s = unsafe { (*c).session };
    }
    if wl.is_null() && !s.is_null() {
        wl = unsafe { (*s).curw };
    }
    if wp.is_null() && !wl.is_null() {
        wp = unsafe { (*(*wl).window).active };
    }
    if !c.is_null() {
        format_defaults_client(ft, c);
    }
    if !s.is_null() {
        format_defaults_session(ft, s);
    }
    if !wl.is_null() {
        format_defaults_winlink(ft, wl);
    }
    if !wp.is_null() {
        format_defaults_pane(ft, wp);
    }
    pb = unsafe { paste_get_top(std::ptr::null_mut::<*const i8>()) };
    if !pb.is_null() {
        format_defaults_paste_buffer(ft, pb);
    }
}
extern "C" fn format_defaults_session(mut ft: *mut format_tree, mut s: *mut session) {
    (unsafe { (*ft).s = s });
}
extern "C" fn format_defaults_client(mut ft: *mut format_tree, mut c: *mut client) {
    if (unsafe { (*ft).s }).is_null() {
        (unsafe { (*ft).s = (*c).session });
    }
    (unsafe { (*ft).c = c });
}
#[no_mangle]
pub extern "C" fn format_defaults_window(mut ft: *mut format_tree, mut w: *mut window) {
    (unsafe { (*ft).w = w });
}
extern "C" fn format_defaults_winlink(mut ft: *mut format_tree, mut wl: *mut winlink) {
    if (unsafe { (*ft).w }).is_null() {
        format_defaults_window(ft, unsafe { (*wl).window });
    }
    (unsafe { (*ft).wl = wl });
}
#[no_mangle]
pub extern "C" fn format_defaults_pane(mut ft: *mut format_tree, mut wp: *mut window_pane) {
    let mut wme: *mut window_mode_entry = std::ptr::null_mut::<window_mode_entry>();
    if (unsafe { (*ft).w }).is_null() {
        format_defaults_window(ft, unsafe { (*wp).window });
    }
    (unsafe { (*ft).wp = wp });
    wme = unsafe { (*wp).modes.tqh_first };
    if !wme.is_null() && (unsafe { ((*(*wme).mode).formats).is_some() }) {
        (unsafe { ((*(*wme).mode).formats).expect("non-null function pointer")(wme, ft) });
    }
}
#[no_mangle]
pub extern "C" fn format_defaults_paste_buffer(
    mut ft: *mut format_tree,
    mut pb: *mut paste_buffer,
) {
    (unsafe { (*ft).pb = pb });
}
extern "C" fn format_is_word_separator(mut ws: *const i8, mut gc: *const grid_cell) -> i32 {
    if (unsafe { utf8_cstrhas(ws, &(*gc).data) }) != 0 {
        return 1 as i32;
    }
    if (unsafe { (*gc).flags }) as i32 & 0x80 as i32 != 0 {
        return 1 as i32;
    }
    return ((unsafe { (*gc).data.size }) as i32 == 1 as i32
        && (unsafe { *((*gc).data.data).as_ptr() }) as i32 == ' ' as i32) as i32;
}
#[no_mangle]
pub extern "C" fn format_grid_word(mut gd: *mut grid, mut x: u_int, mut y: u_int) -> *mut i8 {
    let mut gl: *const grid_line = std::ptr::null::<grid_line>();
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    let mut ws: *const i8 = std::ptr::null::<i8>();
    let mut ud: *mut utf8_data = std::ptr::null_mut::<utf8_data>();
    let mut end: u_int = 0;
    let mut size: size_t = 0 as i32 as size_t;
    let mut found: i32 = 0 as i32;
    let mut s: *mut i8 = std::ptr::null_mut::<i8>();
    ws = unsafe {
        options_get_string(
            global_s_options,
            b"word-separators\0" as *const u8 as *const i8,
        )
    };
    loop {
        (unsafe { grid_get_cell(gd, x, y, &mut gc) });
        if gc.flags as i32 & 0x4 as i32 != 0 {
            break;
        }
        if format_is_word_separator(ws, &mut gc) != 0 {
            found = 1 as i32;
            break;
        } else {
            if x == 0 as i32 as u32 {
                if y == 0 as i32 as u32 {
                    break;
                }
                gl = unsafe { grid_peek_line(gd, y.wrapping_sub(1 as i32 as u32)) };
                if !(unsafe { (*gl).flags }) & 0x1 as i32 != 0 {
                    break;
                }
                y = y.wrapping_sub(1);
                x = unsafe { grid_line_length(gd, y) };
                if x == 0 as i32 as u32 {
                    break;
                }
            }
            x = x.wrapping_sub(1);
        }
    }
    loop {
        if found != 0 {
            end = unsafe { grid_line_length(gd, y) };
            if end == 0 as i32 as u32 || x == end.wrapping_sub(1 as i32 as u32) {
                if y == (unsafe { (*gd).hsize })
                    .wrapping_add(unsafe { (*gd).sy })
                    .wrapping_sub(1 as i32 as u32)
                {
                    break;
                }
                gl = unsafe { grid_peek_line(gd, y) };
                if !(unsafe { (*gl).flags }) & 0x1 as i32 != 0 {
                    break;
                }
                y = y.wrapping_add(1);
                x = 0 as i32 as u_int;
            } else {
                x = x.wrapping_add(1);
            }
        }
        found = 1 as i32;
        (unsafe { grid_get_cell(gd, x, y, &mut gc) });
        if gc.flags as i32 & 0x4 as i32 != 0 {
            break;
        }
        if format_is_word_separator(ws, &mut gc) != 0 {
            break;
        }
        ud = (unsafe {
            xreallocarray(
                ud as *mut libc::c_void,
                size.wrapping_add(2 as i32 as u64),
                ::core::mem::size_of::<utf8_data>() as u64,
            )
        }) as *mut utf8_data;
        let fresh20 = size;
        size = size.wrapping_add(1);
        (unsafe {
            memcpy(
                &mut *ud.offset(fresh20 as isize) as *mut utf8_data as *mut libc::c_void,
                &mut gc.data as *mut utf8_data as *const libc::c_void,
                ::core::mem::size_of::<utf8_data>() as u64,
            )
        });
    }
    if size != 0 as i32 as u64 {
        (unsafe { (*ud.offset(size as isize)).size = 0 as i32 as u_char });
        s = unsafe { utf8_tocstr(ud) };
        (unsafe { free(ud as *mut libc::c_void) });
    }
    return s;
}
#[no_mangle]
pub extern "C" fn format_grid_line(mut gd: *mut grid, mut y: u_int) -> *mut i8 {
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    let mut ud: *mut utf8_data = std::ptr::null_mut::<utf8_data>();
    let mut x: u_int = 0;
    let mut size: size_t = 0 as i32 as size_t;
    let mut s: *mut i8 = std::ptr::null_mut::<i8>();
    x = 0 as i32 as u_int;
    while x < (unsafe { grid_line_length(gd, y) }) {
        (unsafe { grid_get_cell(gd, x, y, &mut gc) });
        if gc.flags as i32 & 0x4 as i32 == 0 {
            ud = (unsafe {
                xreallocarray(
                    ud as *mut libc::c_void,
                    size.wrapping_add(2 as i32 as u64),
                    ::core::mem::size_of::<utf8_data>() as u64,
                )
            }) as *mut utf8_data;
            if gc.flags as i32 & 0x80 as i32 != 0 {
                let fresh21 = size;
                size = size.wrapping_add(1);
                (unsafe { utf8_set(&mut *ud.offset(fresh21 as isize), '\t' as i32 as u_char) });
            } else {
                let fresh22 = size;
                size = size.wrapping_add(1);
                (unsafe {
                    memcpy(
                        &mut *ud.offset(fresh22 as isize) as *mut utf8_data as *mut libc::c_void,
                        &mut gc.data as *mut utf8_data as *const libc::c_void,
                        ::core::mem::size_of::<utf8_data>() as u64,
                    )
                });
            }
        }
        x = x.wrapping_add(1);
    }
    if size != 0 as i32 as u64 {
        (unsafe { (*ud.offset(size as isize)).size = 0 as i32 as u_char });
        s = unsafe { utf8_tocstr(ud) };
        (unsafe { free(ud as *mut libc::c_void) });
    }
    return s;
}
#[no_mangle]
pub extern "C" fn format_grid_hyperlink(
    mut gd: *mut grid,
    mut x: u_int,
    mut y: u_int,
    mut s: *mut screen,
) -> *mut i8 {
    let mut uri: *const i8 = std::ptr::null::<i8>();
    let mut gc: grid_cell = grid_cell {
        data: utf8_data {
            data: [0; 21],
            have: 0,
            size: 0,
            width: 0,
        },
        attr: 0,
        flags: 0,
        fg: 0,
        bg: 0,
        us: 0,
        link: 0,
    };
    (unsafe { grid_get_cell(gd, x, y, &mut gc) });
    if gc.flags as i32 & 0x4 as i32 != 0 {
        return std::ptr::null_mut::<i8>();
    }
    if (unsafe { (*s).hyperlinks }).is_null() || gc.link == 0 as i32 as u32 {
        return std::ptr::null_mut::<i8>();
    }
    if (unsafe {
        hyperlinks_get(
            (*s).hyperlinks,
            gc.link,
            &mut uri,
            std::ptr::null_mut::<*const i8>(),
            std::ptr::null_mut::<*const i8>(),
        )
    }) == 0
    {
        return std::ptr::null_mut::<i8>();
    }
    return unsafe { xstrdup(uri) };
}
